Compare commits

...

No commits in common. "master" and "home" have entirely different histories.
master ... home

58 changed files with 126 additions and 3087 deletions

3
.gitignore vendored
View File

@ -1,2 +1 @@
/node_modules/ /node_modules/
/miniprogram/miniprogram_npm/

View File

@ -1,15 +0,0 @@
### 积分兑换微信小程序
#### 下载代码
```shell
git clone https://git.wm-app.xyz/project/point_sys_miniapp.git
```
#### 初始化依赖
```shell
npm i
或者
yarn install
```
#### 构建npm
打开微信开发者工具,然后点击菜单栏->工具->构建npm
#### 开始开发

View File

@ -1,12 +1,7 @@
{ {
"pages": [ "pages": [
"pages/index/index",
"pages/personal/personal",
"pages/sign/index",
"pages/user/login", "pages/user/login",
"pages/logs/logs", "pages/index/index"
"pages/order/index",
"pages/order/detail"
], ],
"window": { "window": {
"backgroundTextStyle": "light", "backgroundTextStyle": "light",
@ -14,34 +9,6 @@
"navigationBarTitleText": "Weixin", "navigationBarTitleText": "Weixin",
"navigationBarTextStyle": "black" "navigationBarTextStyle": "black"
}, },
"tabBar": { "style": "v2",
"list": [{ "sitemapLocation": "sitemap.json"
"pagePath": "pages/index/index",
"iconPath": "assets/images/icon_home.png",
"selectedIconPath": "assets/images/icon_home_selected.png",
"text": "首页"
},
{
"pagePath": "pages/order/index",
"iconPath": "assets/images/icon_order.png",
"selectedIconPath": "assets/images/icon_order_selected.png",
"text": "订单"
},
{
"pagePath": "pages/personal/personal",
"iconPath": "assets/images/icon_user.png",
"selectedIconPath": "assets/images/icon_user_selected.png",
"text": "个人中心"
}
]
},
"sitemapLocation": "sitemap.json",
"usingComponents": {
"v-button": "@vant/weapp/button/index",
"v-tab": "@vant/weapp/tab/index",
"v-tabs": "@vant/weapp/tabs/index",
"van-dialog": "@vant/weapp/dialog/index",
"van-cell": "@vant/weapp/cell/index",
"van-cell-group": "@vant/weapp/cell-group/index"
}
} }

View File

@ -1,156 +0,0 @@
@font-face {
font-family: "iconfont"; /* Project id 3795683 */
src: url('https://at.alicdn.com/t/c/font_3795683_hbxadrued4a.woff2?t=1676964840714') format('woff2'),
url('https://at.alicdn.com/t/c/font_3795683_hbxadrued4a.woff?t=1676964840714') format('woff'),
url('https://at.alicdn.com/t/c/font_3795683_hbxadrued4a.ttf?t=1676964840714') format('truetype');
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-game:before {
content: "\e6df";
}
.icon-gift:before {
content: "\e681";
}
.icon-sign-in:before {
content: "\e60d";
}
.icon-nav_profile:before {
content: "\e669";
}
.icon-vip-fill:before {
content: "\e78f";
}
.icon-f-coupon:before {
content: "\e778";
}
.icon-collection:before {
content: "\e6a5";
}
.icon-clear:before {
content: "\e649";
}
.icon-circle:before {
content: "\e7b1";
}
.icon-date:before {
content: "\e689";
}
.icon-qrcode:before {
content: "\e7dd";
}
.icon-cash:before {
content: "\e656";
}
.icon-clear1:before {
content: "\e600";
}
.icon-vips:before {
content: "\e662";
}
.icon-search:before {
content: "\e67d";
}
/**global style**/
image{
max-width: 100%;
max-height: 100%;
}
/**app.wxss**/
@content-widht:90%;
.content-container{
width: @content-widht;
margin: auto;
}
.content-bg {
// background: linear-gradient(to bottom, #ceb17f 60%, #fff);
background-color: #ceb17f;
height: 140px;
width: 100%;
left: 0;
top: 0;
position: absolute;
}
.content-wrapper {
position: relative;
z-index: 2;
width: 90vw;
margin: auto;
padding: 10px 0;
font-size: 14px;
}
.user-info {
.header {
color: white;
width: 100%;
padding: 20px 0;
.content-container {
display: flex;
justify-content: space-between;
align-items: center;
}
.user-info {
display: flex;
align-items: center;
}
.user-avatar-wrapper {
width: 60px;
height: 60px;
border-radius: 50%;
display: inline-block;
overflow: hidden;
}
.nickname {
margin-left: 10px;
font-size: 20px;
}
.user-avatar {
width: 100%;
height: 100%;
display: block;
}
}
}
// 列表样式
.list{
background-color: white;
.list-title{}
.list-items{}
.item{
display: flex;
}
}
button[disabled],
button[aria-disabled=true]{
background-color: rgb(78, 61, 61);
}

View File

@ -1,47 +1,11 @@
import { info } from "./service/user-api";
// app.ts // app.ts
App<IAppOption>({ App<IAppOption>({
globalData: {}, globalData: {},
onLaunch() { onLaunch() {
this.updateUserInfo(); // 展示本地存储能力
const token = wx.getStorageSync('user-token')
if (token) {
this.globalData.token = token;
}
}, },
initLoginInfo(resolve, reject) {
wx.login({
fail: reject,
success: (e) => {
if (e.code) {
info(e.code).then(userinfo => {
if (userinfo.token) {
wx.setStorageSync("user-token", userinfo.token)
}
this.globalData.userInfo = userinfo;
resolve(userinfo);
}).catch(reject)
}
}
})
},
updateUserInfo() {
return new Promise<UserInfo>((resolve, reject) => {
// 展示本地存储能力
const token = wx.getStorageSync('user-token')
if (token) {
this.globalData.token = token;
info('', false).then(userinfo => {
console.log(userinfo)
this.globalData.userInfo = userinfo;
resolve(userinfo);
}).catch((e) => {
if (e.code == 403) {
this.initLoginInfo(resolve, reject)
return;
}
reject(e)
})
} else {
this.initLoginInfo(resolve, reject)
}
})
}
}) })

View File

@ -1,539 +0,0 @@
/* Logo 字体 */
@font-face {
font-family: "iconfont logo";
src: url('https://at.alicdn.com/t/font_985780_km7mi63cihi.eot?t=1545807318834');
src: url('https://at.alicdn.com/t/font_985780_km7mi63cihi.eot?t=1545807318834#iefix') format('embedded-opentype'),
url('https://at.alicdn.com/t/font_985780_km7mi63cihi.woff?t=1545807318834') format('woff'),
url('https://at.alicdn.com/t/font_985780_km7mi63cihi.ttf?t=1545807318834') format('truetype'),
url('https://at.alicdn.com/t/font_985780_km7mi63cihi.svg?t=1545807318834#iconfont') format('svg');
}
.logo {
font-family: "iconfont logo";
font-size: 160px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* tabs */
.nav-tabs {
position: relative;
}
.nav-tabs .nav-more {
position: absolute;
right: 0;
bottom: 0;
height: 42px;
line-height: 42px;
color: #666;
}
#tabs {
border-bottom: 1px solid #eee;
}
#tabs li {
cursor: pointer;
width: 100px;
height: 40px;
line-height: 40px;
text-align: center;
font-size: 16px;
border-bottom: 2px solid transparent;
position: relative;
z-index: 1;
margin-bottom: -1px;
color: #666;
}
#tabs .active {
border-bottom-color: #f00;
color: #222;
}
.tab-container .content {
display: none;
}
/* 页面布局 */
.main {
padding: 30px 100px;
width: 960px;
margin: 0 auto;
}
.main .logo {
color: #333;
text-align: left;
margin-bottom: 30px;
line-height: 1;
height: 110px;
margin-top: -50px;
overflow: hidden;
*zoom: 1;
}
.main .logo a {
font-size: 160px;
color: #333;
}
.helps {
margin-top: 40px;
}
.helps pre {
padding: 20px;
margin: 10px 0;
border: solid 1px #e7e1cd;
background-color: #fffdef;
overflow: auto;
}
.icon_lists {
width: 100% !important;
overflow: hidden;
*zoom: 1;
}
.icon_lists li {
width: 100px;
margin-bottom: 10px;
margin-right: 20px;
text-align: center;
list-style: none !important;
cursor: default;
}
.icon_lists li .code-name {
line-height: 1.2;
}
.icon_lists .icon {
display: block;
height: 100px;
line-height: 100px;
font-size: 42px;
margin: 10px auto;
color: #333;
-webkit-transition: font-size 0.25s linear, width 0.25s linear;
-moz-transition: font-size 0.25s linear, width 0.25s linear;
transition: font-size 0.25s linear, width 0.25s linear;
}
.icon_lists .icon:hover {
font-size: 100px;
}
.icon_lists .svg-icon {
/* 通过设置 font-size 来改变图标大小 */
width: 1em;
/* 图标和文字相邻时,垂直对齐 */
vertical-align: -0.15em;
/* 通过设置 color 来改变 SVG 的颜色/fill */
fill: currentColor;
/* path stroke 溢出 viewBox 部分在 IE 下会显示
normalize.css 中也包含这行 */
overflow: hidden;
}
.icon_lists li .name,
.icon_lists li .code-name {
color: #666;
}
/* markdown 样式 */
.markdown {
color: #666;
font-size: 14px;
line-height: 1.8;
}
.highlight {
line-height: 1.5;
}
.markdown img {
vertical-align: middle;
max-width: 100%;
}
.markdown h1 {
color: #404040;
font-weight: 500;
line-height: 40px;
margin-bottom: 24px;
}
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
color: #404040;
margin: 1.6em 0 0.6em 0;
font-weight: 500;
clear: both;
}
.markdown h1 {
font-size: 28px;
}
.markdown h2 {
font-size: 22px;
}
.markdown h3 {
font-size: 16px;
}
.markdown h4 {
font-size: 14px;
}
.markdown h5 {
font-size: 12px;
}
.markdown h6 {
font-size: 12px;
}
.markdown hr {
height: 1px;
border: 0;
background: #e9e9e9;
margin: 16px 0;
clear: both;
}
.markdown p {
margin: 1em 0;
}
.markdown>p,
.markdown>blockquote,
.markdown>.highlight,
.markdown>ol,
.markdown>ul {
width: 80%;
}
.markdown ul>li {
list-style: circle;
}
.markdown>ul li,
.markdown blockquote ul>li {
margin-left: 20px;
padding-left: 4px;
}
.markdown>ul li p,
.markdown>ol li p {
margin: 0.6em 0;
}
.markdown ol>li {
list-style: decimal;
}
.markdown>ol li,
.markdown blockquote ol>li {
margin-left: 20px;
padding-left: 4px;
}
.markdown code {
margin: 0 3px;
padding: 0 5px;
background: #eee;
border-radius: 3px;
}
.markdown strong,
.markdown b {
font-weight: 600;
}
.markdown>table {
border-collapse: collapse;
border-spacing: 0px;
empty-cells: show;
border: 1px solid #e9e9e9;
width: 95%;
margin-bottom: 24px;
}
.markdown>table th {
white-space: nowrap;
color: #333;
font-weight: 600;
}
.markdown>table th,
.markdown>table td {
border: 1px solid #e9e9e9;
padding: 8px 16px;
text-align: left;
}
.markdown>table th {
background: #F7F7F7;
}
.markdown blockquote {
font-size: 90%;
color: #999;
border-left: 4px solid #e9e9e9;
padding-left: 0.8em;
margin: 1em 0;
}
.markdown blockquote p {
margin: 0;
}
.markdown .anchor {
opacity: 0;
transition: opacity 0.3s ease;
margin-left: 8px;
}
.markdown .waiting {
color: #ccc;
}
.markdown h1:hover .anchor,
.markdown h2:hover .anchor,
.markdown h3:hover .anchor,
.markdown h4:hover .anchor,
.markdown h5:hover .anchor,
.markdown h6:hover .anchor {
opacity: 1;
display: inline-block;
}
.markdown>br,
.markdown>p>br {
clear: both;
}
.hljs {
display: block;
background: white;
padding: 0.5em;
color: #333333;
overflow-x: auto;
}
.hljs-comment,
.hljs-meta {
color: #969896;
}
.hljs-string,
.hljs-variable,
.hljs-template-variable,
.hljs-strong,
.hljs-emphasis,
.hljs-quote {
color: #df5000;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-type {
color: #a71d5d;
}
.hljs-literal,
.hljs-symbol,
.hljs-bullet,
.hljs-attribute {
color: #0086b3;
}
.hljs-section,
.hljs-name {
color: #63a35c;
}
.hljs-tag {
color: #333333;
}
.hljs-title,
.hljs-attr,
.hljs-selector-id,
.hljs-selector-class,
.hljs-selector-attr,
.hljs-selector-pseudo {
color: #795da3;
}
.hljs-addition {
color: #55a532;
background-color: #eaffea;
}
.hljs-deletion {
color: #bd2c00;
background-color: #ffecec;
}
.hljs-link {
text-decoration: underline;
}
/* 代码高亮 */
/* PrismJS 1.15.0
https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript */
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/
code[class*="language-"],
pre[class*="language-"] {
color: black;
background: none;
text-shadow: 0 1px white;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection,
pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection,
code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}
pre[class*="language-"]::selection,
pre[class*="language-"] ::selection,
code[class*="language-"]::selection,
code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}
@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}
:not(pre)>code[class*="language-"],
pre[class*="language-"] {
background: #f5f2f0;
}
/* Inline code */
:not(pre)>code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}
.token.punctuation {
color: #999;
}
.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #905;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #690;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #9a6e3a;
background: hsla(0, 0%, 100%, .5);
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}
.token.function,
.token.class-name {
color: #DD4A68;
}
.token.regex,
.token.important,
.token.variable {
color: #e90;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}

View File

@ -1,533 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>iconfont Demo</title>
<link rel="shortcut icon" href="//img.alicdn.com/imgextra/i4/O1CN01Z5paLz1O0zuCC7osS_!!6000000001644-55-tps-83-82.svg" type="image/x-icon"/>
<link rel="icon" type="image/svg+xml" href="//img.alicdn.com/imgextra/i4/O1CN01Z5paLz1O0zuCC7osS_!!6000000001644-55-tps-83-82.svg"/>
<link rel="stylesheet" href="https://g.alicdn.com/thx/cube/1.3.2/cube.min.css">
<link rel="stylesheet" href="demo.css">
<link rel="stylesheet" href="iconfont.css">
<script src="iconfont.js"></script>
<!-- jQuery -->
<script src="https://a1.alicdn.com/oss/uploads/2018/12/26/7bfddb60-08e8-11e9-9b04-53e73bb6408b.js"></script>
<!-- 代码高亮 -->
<script src="https://a1.alicdn.com/oss/uploads/2018/12/26/a3f714d0-08e6-11e9-8a15-ebf944d7534c.js"></script>
<style>
.main .logo {
margin-top: 0;
height: auto;
}
.main .logo a {
display: flex;
align-items: center;
}
.main .logo .sub-title {
margin-left: 0.5em;
font-size: 22px;
color: #fff;
background: linear-gradient(-45deg, #3967FF, #B500FE);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
</style>
</head>
<body>
<div class="main">
<h1 class="logo"><a href="https://www.iconfont.cn/" title="iconfont 首页" target="_blank">
<img width="200" src="https://img.alicdn.com/imgextra/i3/O1CN01Mn65HV1FfSEzR6DKv_!!6000000000514-55-tps-228-59.svg">
</a></h1>
<div class="nav-tabs">
<ul id="tabs" class="dib-box">
<li class="dib active"><span>Unicode</span></li>
<li class="dib"><span>Font class</span></li>
<li class="dib"><span>Symbol</span></li>
</ul>
<a href="https://www.iconfont.cn/manage/index?manage_type=myprojects&projectId=3795683" target="_blank" class="nav-more">查看项目</a>
</div>
<div class="tab-container">
<div class="content unicode" style="display: block;">
<ul class="icon_lists dib-box">
<li class="dib">
<span class="icon iconfont">&#xe6df;</span>
<div class="name">game</div>
<div class="code-name">&amp;#xe6df;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe681;</span>
<div class="name">gift</div>
<div class="code-name">&amp;#xe681;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe60d;</span>
<div class="name">sign-in</div>
<div class="code-name">&amp;#xe60d;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe669;</span>
<div class="name">个人信息</div>
<div class="code-name">&amp;#xe669;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe78f;</span>
<div class="name">vip-fill</div>
<div class="code-name">&amp;#xe78f;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe778;</span>
<div class="name">f-coupon</div>
<div class="code-name">&amp;#xe778;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe6a5;</span>
<div class="name">collection</div>
<div class="code-name">&amp;#xe6a5;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe649;</span>
<div class="name">clear</div>
<div class="code-name">&amp;#xe649;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe7b1;</span>
<div class="name">circle</div>
<div class="code-name">&amp;#xe7b1;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe689;</span>
<div class="name">date</div>
<div class="code-name">&amp;#xe689;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe7dd;</span>
<div class="name">qrcode</div>
<div class="code-name">&amp;#xe7dd;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe656;</span>
<div class="name">cash</div>
<div class="code-name">&amp;#xe656;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe600;</span>
<div class="name">clear</div>
<div class="code-name">&amp;#xe600;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe662;</span>
<div class="name">vips</div>
<div class="code-name">&amp;#xe662;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe67d;</span>
<div class="name">search</div>
<div class="code-name">&amp;#xe67d;</div>
</li>
</ul>
<div class="article markdown">
<h2 id="unicode-">Unicode 引用</h2>
<hr>
<p>Unicode 是字体在网页端最原始的应用方式,特点是:</p>
<ul>
<li>支持按字体的方式去动态调整图标大小,颜色等等。</li>
<li>默认情况下不支持多色,直接添加多色图标会自动去色。</li>
</ul>
<blockquote>
<p>注意:新版 iconfont 支持两种方式引用多色图标SVG symbol 引用方式和彩色字体图标模式。(使用彩色字体图标需要在「编辑项目」中开启「彩色」选项后并重新生成。)</p>
</blockquote>
<p>Unicode 使用步骤如下:</p>
<h3 id="-font-face">第一步:拷贝项目下面生成的 <code>@font-face</code></h3>
<pre><code class="language-css"
>@font-face {
font-family: 'iconfont';
src: url('iconfont.woff2?t=1669628868947') format('woff2'),
url('iconfont.woff?t=1669628868947') format('woff'),
url('iconfont.ttf?t=1669628868947') format('truetype');
}
</code></pre>
<h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
<pre><code class="language-css"
>.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
</code></pre>
<h3 id="-">第三步:挑选相应图标并获取字体编码,应用于页面</h3>
<pre>
<code class="language-html"
>&lt;span class="iconfont"&gt;&amp;#x33;&lt;/span&gt;
</code></pre>
<blockquote>
<p>"iconfont" 是你项目下的 font-family。可以通过编辑项目查看默认是 "iconfont"。</p>
</blockquote>
</div>
</div>
<div class="content font-class">
<ul class="icon_lists dib-box">
<li class="dib">
<span class="icon iconfont icon-game"></span>
<div class="name">
game
</div>
<div class="code-name">.icon-game
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-gift"></span>
<div class="name">
gift
</div>
<div class="code-name">.icon-gift
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-sign-in"></span>
<div class="name">
sign-in
</div>
<div class="code-name">.icon-sign-in
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-nav_profile"></span>
<div class="name">
个人信息
</div>
<div class="code-name">.icon-nav_profile
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-vip-fill"></span>
<div class="name">
vip-fill
</div>
<div class="code-name">.icon-vip-fill
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-f-coupon"></span>
<div class="name">
f-coupon
</div>
<div class="code-name">.icon-f-coupon
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-collection"></span>
<div class="name">
collection
</div>
<div class="code-name">.icon-collection
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-clear"></span>
<div class="name">
clear
</div>
<div class="code-name">.icon-clear
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-circle"></span>
<div class="name">
circle
</div>
<div class="code-name">.icon-circle
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-date"></span>
<div class="name">
date
</div>
<div class="code-name">.icon-date
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-qrcode"></span>
<div class="name">
qrcode
</div>
<div class="code-name">.icon-qrcode
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-cash"></span>
<div class="name">
cash
</div>
<div class="code-name">.icon-cash
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-clear1"></span>
<div class="name">
clear
</div>
<div class="code-name">.icon-clear1
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-vips"></span>
<div class="name">
vips
</div>
<div class="code-name">.icon-vips
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-search"></span>
<div class="name">
search
</div>
<div class="code-name">.icon-search
</div>
</li>
</ul>
<div class="article markdown">
<h2 id="font-class-">font-class 引用</h2>
<hr>
<p>font-class 是 Unicode 使用方式的一种变种,主要是解决 Unicode 书写不直观,语意不明确的问题。</p>
<p>与 Unicode 使用方式相比,具有如下特点:</p>
<ul>
<li>相比于 Unicode 语意明确,书写更直观。可以很容易分辨这个 icon 是什么。</li>
<li>因为使用 class 来定义图标,所以当要替换图标时,只需要修改 class 里面的 Unicode 引用。</li>
</ul>
<p>使用步骤如下:</p>
<h3 id="-fontclass-">第一步:引入项目下面生成的 fontclass 代码:</h3>
<pre><code class="language-html">&lt;link rel="stylesheet" href="./iconfont.css"&gt;
</code></pre>
<h3 id="-">第二步:挑选相应图标并获取类名,应用于页面:</h3>
<pre><code class="language-html">&lt;span class="iconfont icon-xxx"&gt;&lt;/span&gt;
</code></pre>
<blockquote>
<p>"
iconfont" 是你项目下的 font-family。可以通过编辑项目查看默认是 "iconfont"。</p>
</blockquote>
</div>
</div>
<div class="content symbol">
<ul class="icon_lists dib-box">
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-game"></use>
</svg>
<div class="name">game</div>
<div class="code-name">#icon-game</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-gift"></use>
</svg>
<div class="name">gift</div>
<div class="code-name">#icon-gift</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-sign-in"></use>
</svg>
<div class="name">sign-in</div>
<div class="code-name">#icon-sign-in</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-nav_profile"></use>
</svg>
<div class="name">个人信息</div>
<div class="code-name">#icon-nav_profile</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-vip-fill"></use>
</svg>
<div class="name">vip-fill</div>
<div class="code-name">#icon-vip-fill</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-f-coupon"></use>
</svg>
<div class="name">f-coupon</div>
<div class="code-name">#icon-f-coupon</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-collection"></use>
</svg>
<div class="name">collection</div>
<div class="code-name">#icon-collection</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-clear"></use>
</svg>
<div class="name">clear</div>
<div class="code-name">#icon-clear</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-circle"></use>
</svg>
<div class="name">circle</div>
<div class="code-name">#icon-circle</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-date"></use>
</svg>
<div class="name">date</div>
<div class="code-name">#icon-date</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-qrcode"></use>
</svg>
<div class="name">qrcode</div>
<div class="code-name">#icon-qrcode</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-cash"></use>
</svg>
<div class="name">cash</div>
<div class="code-name">#icon-cash</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-clear1"></use>
</svg>
<div class="name">clear</div>
<div class="code-name">#icon-clear1</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-vips"></use>
</svg>
<div class="name">vips</div>
<div class="code-name">#icon-vips</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-search"></use>
</svg>
<div class="name">search</div>
<div class="code-name">#icon-search</div>
</li>
</ul>
<div class="article markdown">
<h2 id="symbol-">Symbol 引用</h2>
<hr>
<p>这是一种全新的使用方式,应该说这才是未来的主流,也是平台目前推荐的用法。相关介绍可以参考这篇<a href="">文章</a>
这种用法其实是做了一个 SVG 的集合,与另外两种相比具有如下特点:</p>
<ul>
<li>支持多色图标了,不再受单色限制。</li>
<li>通过一些技巧,支持像字体那样,通过 <code>font-size</code>, <code>color</code> 来调整样式。</li>
<li>兼容性较差,支持 IE9+,及现代浏览器。</li>
<li>浏览器渲染 SVG 的性能一般,还不如 png。</li>
</ul>
<p>使用步骤如下:</p>
<h3 id="-symbol-">第一步:引入项目下面生成的 symbol 代码:</h3>
<pre><code class="language-html">&lt;script src="./iconfont.js"&gt;&lt;/script&gt;
</code></pre>
<h3 id="-css-">第二步:加入通用 CSS 代码(引入一次就行):</h3>
<pre><code class="language-html">&lt;style&gt;
.icon {
width: 1em;
height: 1em;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
}
&lt;/style&gt;
</code></pre>
<h3 id="-">第三步:挑选相应图标并获取类名,应用于页面:</h3>
<pre><code class="language-html">&lt;svg class="icon" aria-hidden="true"&gt;
&lt;use xlink:href="#icon-xxx"&gt;&lt;/use&gt;
&lt;/svg&gt;
</code></pre>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$('.tab-container .content:first').show()
$('#tabs li').click(function (e) {
var tabContent = $('.tab-container .content')
var index = $(this).index()
if ($(this).hasClass('active')) {
return
} else {
$('#tabs li').removeClass('active')
$(this).addClass('active')
tabContent.hide().eq(index).fadeIn()
}
})
})
</script>
</body>
</html>

View File

@ -1,75 +0,0 @@
@font-face {
font-family: "iconfont"; /* Project id 3795683 */
src: url('iconfont.woff2?t=1669628868947') format('woff2'),
url('iconfont.woff?t=1669628868947') format('woff'),
url('iconfont.ttf?t=1669628868947') format('truetype');
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-game:before {
content: "\e6df";
}
.icon-gift:before {
content: "\e681";
}
.icon-sign-in:before {
content: "\e60d";
}
.icon-nav_profile:before {
content: "\e669";
}
.icon-vip-fill:before {
content: "\e78f";
}
.icon-f-coupon:before {
content: "\e778";
}
.icon-collection:before {
content: "\e6a5";
}
.icon-clear:before {
content: "\e649";
}
.icon-circle:before {
content: "\e7b1";
}
.icon-date:before {
content: "\e689";
}
.icon-qrcode:before {
content: "\e7dd";
}
.icon-cash:before {
content: "\e656";
}
.icon-clear1:before {
content: "\e600";
}
.icon-vips:before {
content: "\e662";
}
.icon-search:before {
content: "\e67d";
}

File diff suppressed because one or more lines are too long

View File

@ -1,114 +0,0 @@
{
"id": "3795683",
"name": "point",
"font_family": "iconfont",
"css_prefix_text": "icon-",
"description": "",
"glyphs": [
{
"icon_id": "41958",
"name": "game",
"font_class": "game",
"unicode": "e6df",
"unicode_decimal": 59103
},
{
"icon_id": "248956",
"name": "gift",
"font_class": "gift",
"unicode": "e681",
"unicode_decimal": 59009
},
{
"icon_id": "1238496",
"name": "sign-in",
"font_class": "sign-in",
"unicode": "e60d",
"unicode_decimal": 58893
},
{
"icon_id": "3550634",
"name": "个人信息",
"font_class": "nav_profile",
"unicode": "e669",
"unicode_decimal": 58985
},
{
"icon_id": "11488335",
"name": "vip-fill",
"font_class": "vip-fill",
"unicode": "e78f",
"unicode_decimal": 59279
},
{
"icon_id": "12773718",
"name": "f-coupon",
"font_class": "f-coupon",
"unicode": "e778",
"unicode_decimal": 59256
},
{
"icon_id": "16618139",
"name": "collection",
"font_class": "collection",
"unicode": "e6a5",
"unicode_decimal": 59045
},
{
"icon_id": "736618",
"name": "clear",
"font_class": "clear",
"unicode": "e649",
"unicode_decimal": 58953
},
{
"icon_id": "833469",
"name": "circle",
"font_class": "circle",
"unicode": "e7b1",
"unicode_decimal": 59313
},
{
"icon_id": "1226191",
"name": "date",
"font_class": "date",
"unicode": "e689",
"unicode_decimal": 59017
},
{
"icon_id": "4766912",
"name": "qrcode",
"font_class": "qrcode",
"unicode": "e7dd",
"unicode_decimal": 59357
},
{
"icon_id": "5776872",
"name": "cash",
"font_class": "cash",
"unicode": "e656",
"unicode_decimal": 58966
},
{
"icon_id": "9358624",
"name": "clear",
"font_class": "clear1",
"unicode": "e600",
"unicode_decimal": 58880
},
{
"icon_id": "11903732",
"name": "vips",
"font_class": "vips",
"unicode": "e662",
"unicode_decimal": 58978
},
{
"icon_id": "15838525",
"name": "search",
"font_class": "search",
"unicode": "e67d",
"unicode_decimal": 59005
}
]
}

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -1 +0,0 @@
<svg class="svg-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3698"><path d="M584.704 998.4H439.296c-228.352 0-413.696-185.344-413.696-413.696V439.296c0-228.352 185.344-413.696 413.696-413.696h145.408c228.352 0 413.696 185.344 413.696 413.696v145.408c0 228.352-185.344 413.696-413.696 413.696z" fill="#FF9A23" p-id="3699"></path><path d="M998.4 584.704V439.296c0-228.352-185.344-413.696-413.696-413.696H439.296C210.944 25.6 25.6 210.944 25.6 439.296v145.408c0 228.352 185.344 413.696 413.696 413.696h145.408c13.312 0 26.624-1.024 38.912-2.048 162.816-61.44 294.912-185.344 368.64-342.016 4.096-22.528 6.144-46.08 6.144-69.632z" fill="#FF9A23" p-id="3700"></path><path d="M584.704 25.6H439.296C210.944 25.6 25.6 210.944 25.6 439.296v145.408c0 158.72 90.112 296.96 222.208 366.592 45.056 10.24 91.136 16.384 139.264 16.384C715.776 967.68 983.04 700.416 983.04 371.712c0-17.408-1.024-34.816-2.048-51.2-51.2-171.008-208.896-294.912-396.288-294.912z" fill="#FF9F23" p-id="3701"></path><path d="M911.36 371.712c0-91.136-23.552-177.152-64.512-252.928-71.68-58.368-161.792-93.184-261.12-93.184H439.296C210.944 25.6 25.6 210.944 25.6 439.296v145.408c0 78.848 22.528 153.6 61.44 216.064 84.992 59.392 188.416 94.208 300.032 94.208C675.84 896 911.36 660.48 911.36 371.712z" fill="#FFA423" p-id="3702"></path><path d="M439.296 25.6C210.944 25.6 25.6 210.944 25.6 439.296v145.408c0 22.528 2.048 44.032 5.12 65.536 82.944 105.472 210.944 173.056 356.352 173.056C636.928 823.296 839.68 620.544 839.68 370.688 838.656 240.64 783.36 122.88 695.296 40.96c-34.816-9.216-71.68-15.36-109.568-15.36H439.296z" fill="#FFAA23" p-id="3703"></path><path d="M544.768 25.6H439.296C210.944 25.6 25.6 210.944 25.6 439.296v51.2c52.224 158.72 205.824 271.36 385.024 260.096 189.44-11.264 343.04-163.84 355.328-353.28 11.264-163.84-82.944-308.224-221.184-371.712z" fill="#FFAF23" p-id="3704"></path><path d="M391.168 375.808m-308.224 0a308.224 308.224 0 1 0 616.448 0 308.224 308.224 0 1 0-616.448 0Z" fill="#FFB423" p-id="3705"></path><path d="M155.648 374.784a235.52 235.52 0 1 0 471.04 0 235.52 235.52 0 1 0-471.04 0Z" fill="#FFB923" p-id="3706"></path><path d="M681.984 340.992c-107.52-107.52-300.032-91.136-380.928 52.224-41.984 72.704-41.984 164.864 0 237.568 80.896 142.336 272.384 159.744 380.928 52.224 93.184-93.184 96.256-248.832 0-342.016zM568.32 572.416c-14.336 14.336-27.648 29.696-37.888 44.032-9.216 12.288-27.648 12.288-36.864 0-11.264-14.336-24.576-29.696-39.936-44.032-15.36-15.36-30.72-29.696-46.08-40.96-11.264-8.192-11.264-25.6 1.024-33.792 15.36-10.24 30.72-23.552 46.08-37.888 16.384-16.384 30.72-34.816 43.008-51.2 7.168-9.216 21.504-9.216 28.672 0 11.264 16.384 25.6 33.792 41.984 50.176 14.336 14.336 30.72 27.648 45.056 38.912 11.264 8.192 12.288 25.6 0 33.792-14.336 10.24-29.696 23.552-45.056 40.96z" fill="#FFFFFF"></path></svg>

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -4,11 +4,11 @@ type ApplicationConfig = {
} }
const ConfigData = { const ConfigData = {
dev: { dev: {
api_url: 'http://192.168.10.64:8080', api_url: 'http://localhost:8001',
env: 'dev' env: 'dev'
}, },
prod: { prod: {
api_url: 'http://192.168.10.64:8001', api_url: 'http://localhost:8001',
env: 'prod' env: 'prod'
} }
} }

View File

@ -1,8 +1,3 @@
{ {
"usingComponents": {}, "usingComponents": {}
"navigationBarBackgroundColor": "#ceb17f",
"navigationBarTitleText": "积分商城",
"navigationBarTextStyle": "white",
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark"
} }

View File

@ -1,169 +0,0 @@
/**index.wxss**/
@box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
image {
width: 100%;
height: 100%;
}
.displex-flex {
display: flex;
}
.box-border-radius {
border-radius: 10px;
overflow: hidden;
}
.goods-cover{
border-radius: 4px;
overflow: hidden;
}
.content-bg {
background: linear-gradient(to bottom, #ceb17f 60%, #fff);
}
// swiper
.top-swiper {
.box-border-radius;
}
.swiper-item {
height: 150px;
}
.index-act-1 {
width: 100%;
height: 100px;
.box-border-radius;
box-shadow: @box-shadow;
margin: 20px 0;
}
.recommend-wrapper,
.hot-wrapper {
margin: 20px 0;
}
.hot-title {
font-weight: bold;
font-size: 16px;
margin-bottom: 10px;
}
// panel
.panel {
.box-border-radius;
box-shadow: @box-shadow;
.panel-title {
font-weight: bold;
font-size: 16px;
padding: 20px 20px 0;
}
.panel-body {
padding: 20px;
}
}
.goods-list-row {
display: flex;
overflow: hidden;
.goods-item {
flex: 1;
min-width: 20%;
margin-right: 10px;
text-align: center;
&:last-child {
margin-right: 0px;
}
}
.image {
width: 100%;
// 长宽的比例
aspect-ratio: 1/1;
.goods-cover;
}
.title {
word-break: break-all;
font-size: 12px;
line-height: 16px;
height: 32px;
overflow: hidden;
margin-top: 5px;
}
.price {
color: #f00;
margin-top: 5px;
}
}
.normal-list {
.goods-item {
.displex-flex;
margin-bottom: 20px;
&:last-child {
margin-bottom: 0;
}
}
.image {
min-width: 80px;
height: 80px;
margin-right: 15px;
.goods-cover;
}
.goods-info{
flex:1;
}
.title {
line-height: 20px;
height: 40px;
overflow: hidden;
font-size: 14px;
word-break: break-all;
}
.goods-action {
margin-top: 10px;
.displex-flex;
justify-content: space-between;
}
.price {
color: red;
font-size: 16px;
line-height: 30px;
}
.actions {
button {
height: 30px;
border-radius: 30px;
font-size: 13px;
background-color: rgba(255, 0, 0, 0.8);
color: white;
width: 100px;
padding: 0;
line-height: 30px;
&.disabled{
background-color: #ddd;
color:#999;
&:active{
background-color: #ddd;
}
}
&:active{
background-color: rgb(233, 0, 0);
}
}
}
}

View File

@ -1,121 +1,49 @@
// index.ts // index.ts
import { createOrder, Goods, queryGoodsList } from "../../service/shop-api"
import message from "../../utils/message";
// 获取应用实例 // 获取应用实例
const app = getApp<IAppOption>() const app = getApp<IAppOption>()
Page({ Page({
data: { data: {
swiperList: [ motto: 'Hello World',
{ userInfo: {},
image: 'https://m15.360buyimg.com/mobilecms/jfs/t1/160398/4/32302/103427/6374d1f3E5b1ecb32/a593b9982d8378cc.jpg!cr_1125x449_0_166!q70.jpg', hasUserInfo: false,
url: null, canIUse: wx.canIUse('button.open-type.getUserInfo'),
id:1, canIUseGetUserProfile: false,
}, canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
{
image: 'https://m15.360buyimg.com/mobilecms/jfs/t1/203775/20/26428/95041/637fab4dEf6a4434d/3f8770efe691537b.jpg!cr_1053x420_4_0!q70.jpg',
url: null,
id:2,
},
{
image: 'https://m15.360buyimg.com/mobilecms/jfs/t1/160398/4/32302/103427/6374d1f3E5b1ecb32/a593b9982d8378cc.jpg!cr_1125x449_0_166!q70.jpg',
url: null,
id:3,
},
{
image: 'https://m15.360buyimg.com/mobilecms/jfs/t1/203775/20/26428/95041/637fab4dEf6a4434d/3f8770efe691537b.jpg!cr_1053x420_4_0!q70.jpg',
url: null,
id:4,
}
],
goodsItems: [],
recommendItems: [],
page: 1,
hasMore: true,
pageSize: 10,
userPoint: -1,
}, },
onPullDownRefresh() { // 事件处理函数
this.setData({ bindViewTap() {
page: 1 wx.navigateTo({
}) url: '../logs/logs',
this.onLoad()
},
onReachBottom() {
if (!this.data.hasMore) return;
const page = this.data.page + 1;
this.setData({ page })
this.loadGoodsList(page)
},
loadGoodsList(page: number) {
// 所有其他的商品
queryGoodsList(1, page, this.data.pageSize).then((result) => {
//判断是否还有数据没有查询到
const count = page * this.data.pageSize;
if (count >= result.total) {
this.setData({
hasMore: false
})
}
const originList = page == 1 ? [] : this.data.goodsItems;
this.setData({
// @ts-ignore
goodsItems: [
...originList,
...result.records
]
})
}) })
}, },
onLoad() { onLoad() {
if(app.globalData.userInfo && app.globalData.userInfo.pointInfo){ // @ts-ignore
if (wx.getUserProfile) {
this.setData({ this.setData({
userPoint: app.globalData.userInfo.pointInfo.totalPoint canIUseGetUserProfile: true
}) })
} }
// 推荐商品
queryGoodsList(2, 1, 3).then((result) => {
wx.stopPullDownRefresh();
this.setData({
// @ts-ignore
recommendItems: result.records
})
})
// 所有其他的商品
this.loadGoodsList(this.data.page);
}, },
createOrder(e: any) { getUserProfile() {
if(!app.globalData.token || !app.globalData.userInfo){ // 推荐使用wx.getUserProfile获取用户信息开发者每次通过该接口获取用户个人信息均需用户确认开发者妥善保管用户快速填写的头像昵称避免重复弹窗
// message.toast('请先完成登录','none',()=>{ wx.getUserProfile({
// }) desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
wx.switchTab({ console.log(res)
url: '/pages/personal/personal' this.setData({
}) userInfo: res.userInfo,
return false; hasUserInfo: true
}
const goods = e.target.dataset.data as Goods;
if(goods.price > app.globalData.userInfo.pointInfo.totalPoint){
message.alert('积分不足')
return;
}
message.confirm('确认兑换此商品吗?').then(b=>{
if(b){
message.showLoading({ message: '兑换中...' })
createOrder(goods.id).then(result => {
console.log(result)
// 更新用户信息
app.updateUserInfo();
message.toast('兑换成功')
}).catch(e => {
message.toast(e.message || '兑换失败')
}).finally(() => {
message.hideLoading()
}) })
} }
}) })
return; },
getUserInfo(e: any) {
// 不推荐使用getUserInfo获取用户信息预计自2021年4月13日起getUserInfo将不再弹出弹窗并直接返回匿名的用户个人信息
console.log(e)
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
} }
}) })

View File

@ -1,83 +1,23 @@
<!--index.wxml--> <!--index.wxml-->
<view class="container"> <view class="container">
<view class="content-bg"></view> <view class="userinfo">
<view class="content-wrapper"> <block wx:if="{{canIUseOpenData}}">
<view class="top-swiper"> <view class="userinfo-avatar" bindtap="bindViewTap">
<swiper indicator-dots="{{true}}" indicator-color="#fff" autoplay="{{true}}"> <open-data type="userAvatarUrl"></open-data>
<block wx:for="{{swiperList}}" wx:key="id">
<swiper-item>
<view class="swiper-item">
<image src="{{item.image}}" />
</view>
</swiper-item>
</block>
</swiper>
</view>
<view class="recommend-wrapper">
<view class="panel">
<view class="panel-title">
<text>精选活动</text>
</view>
<view class="panel-body">
<view class="goods-list goods-list-row">
<view wx:for="{{recommendItems}}" wx:key="id" class="goods-item">
<view class="image">
<image src="{{item.cover}}"></image>
</view>
<view class="title">
<text>{{item.title}}</text>
</view>
<view class="goods-action">
<view class="price">
<text>{{item.price}}积分</text>
</view>
<view class="actions">
</view>
</view>
</view>
</view>
</view>
</view> </view>
</view> <open-data type="userNickName"></open-data>
</block>
<view class="index-act-1"> <block wx:elif="{{!hasUserInfo}}">
<image src="https://file.wx.wm-app.xyz/os/picture/project/uestc/mini-app/18005888-5c529143bfc58.jpg"></image> <button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile"> 获取头像昵称 </button>
</view> <button wx:elif="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<view wx:else> 请使用1.4.4及以上版本基础库 </view>
</block>
<view class="hot-wrapper"> <block wx:else>
<view class="hot-title"> <image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text>热门超值兑换</text> <text class="userinfo-nickname">{{userInfo.nickName}}</text>
</view> </block>
<view class="panel">
<view class="panel-body">
<view class="goods-list normal-list">
<view wx:for="{{goodsItems}}" wx:key="id" class="goods-item">
<view class="image">
<image src="{{item.cover}}"></image>
</view>
<view class="goods-info">
<view class="title">
<text>{{item.title}}</text>
</view>
<view class="goods-action">
<view class="price">
<text>{{item.price}}积分</text>
</view>
<view class="actions">
<button wx:if="{{userPoint > -1 && item.price <= userPoint}}" data-data="{{item}}" bindtap="createOrder">立即兑换</button>
<button wx:else class="disabled" disabled>积分不足</button>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view> </view>
</view> <view class="usermotto">
<text class="user-motto">{{motto}}</text>
</view>
</view>

View File

@ -0,0 +1,19 @@
/**index.wxss**/
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
color: #aaa;
}
.userinfo-avatar {
overflow: hidden;
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.usermotto {
margin-top: 200px;
}

View File

@ -1 +0,0 @@
/* pages/logs/logs.wxss */

View File

@ -1,6 +0,0 @@
{
"usingComponents": {},
"navigationBarBackgroundColor": "#f2f2f2",
"navigationBarTitleText": "订单详情",
"enablePullDownRefresh": true
}

View File

@ -1,87 +0,0 @@
/* pages/order/detail.wxss */
@padding: 15px;
@content_padding: 15px;
.order-detail-page {
background-color: #f2f2f2;
min-height: 100vh;
--padding-xs: 15px;
.order-status {
padding: 20px 30px;
background-color: #ffffff;
font-size: 18px;
}
.order-goods,.order-info-detail {
background-color: #ffffff;
margin: 15px;
border-radius: 10px;
overflow: hidden;
}
.order-info-detail{
font-size: 13px;
padding: 10px 0;
.item {
display: flex;
align-items: center;
padding: 5px 15px;
}
.title{
margin-right: 5px;
}
}
.order-goods-content {
padding: @content_padding;
.info {
display: flex;
}
.goods-name {
flex: 1;
margin: 0 8px;
font-size: 15px;
line-height: 1.3;
}
.goods-price {
color: #999;
text-align: right;
}
.sale-price {
color: #333;
}
.origin-price {
text-decoration: line-through;
}
}
.goods-cover-image {
width: 100px;
height: 100px;
}
.price {
text-align: right;
font-size: 13px;
.price-total {
font-size: 16px;
vertical-align: baseline;
}
}
.order-footer {
border-top: 1px solid #f2f2f2;
overflow: hidden;
padding: 15px;
}
.order-action{
float: right;
}
}

View File

@ -1,69 +0,0 @@
import { queryOrderDetail } from "../../service/shop-api";
import message from "../../utils/message";
// pages/order/detail.ts
Page({
/**
*
*/
data: {
statusEnums: {
1: '待确认',
2: '已确认',
3: '已取消',
4: '已完成',
0: '已删除'
},
id: '',
order: {}
},
/**
* --
*/
onLoad(opts: { id?: string }) {
if (!opts.id) {
message.alert('订单数据错误').then(() => wx.navigateBack());
return;
}
this.setData({
id: opts.id
})
this.loadOrderDetail(opts.id)
},
/**
* --
*/
onReady() {
},
/**
* --
*/
onShow() {
},
/**
* --
*/
onHide() {
},
onPullDownRefresh(){
this.loadOrderDetail()
},
async loadOrderDetail(id?: string) {
message.showLoading()
try{
const order = await queryOrderDetail((id || this.data.id));
this.setData({ order })
wx.stopPullDownRefresh()
}finally{
message.hideLoading()
}
}
})

View File

@ -1,48 +0,0 @@
<!--pages/order/detail.wxml-->
<view class="order-detail-page">
<view class="order-status">
<text>{{statusEnums[order.status]||''}}</text>
</view>
<view class="order-goods">
<view class="order-goods-content">
<view class="info" id="{{order.id}}">
<!-- 商品图片 -->
<view class="goods-cover">
<image class="goods-cover-image" src="{{order.goods.cover}}" />
</view>
<view class="goods-name">
<text>{{order.goods.title}}</text>
</view>
<view class="goods-price">
<view class="sale-price">{{order.goods.price}}</view>
<view wx:if="{{order.goods.originPrice > 0}}" class="origin-price">{{order.goods.originPrice}}</view>
<view class="count">× 1</view>
</view>
</view>
<view class="price">
<text>实付积分:</text>
<text class="price-total">{{order.price}}</text>
</view>
</view>
<view class="order-footer">
<view class="order-action">
<v-button wx:if="{{order.status < 3}}" data-id="{{order.id}}" class="btn" round type="default" size="small">取消订单</v-button>
<v-button data-id="{{order.id}}" class="btn" round type="danger" size="small">删除订单</v-button>
</view>
</view>
</view>
<view class="order-info-detail">
<view class="item">
<view class="title">订单编号:</view>
<view class="value">{{order.id}}</view>
</view>
<view class="item">
<view class="title">创建时间:</view>
<view class="value">{{order.createTime}}</view>
</view>
<view class="item">
<view class="title">更新时间:</view>
<view class="value">{{order.updateTime}}</view>
</view>
</view>
</view>

View File

@ -1,5 +0,0 @@
{
"navigationBarTitleText": "我的订单",
"usingComponents": {
}
}

View File

@ -1,88 +0,0 @@
/* pages/order/index.wxss */
@padding: 15px;
@content_padding: 10px;
.order-page {
background-color: #f2f2f2;
min-height: 100vh;
}
.order-list-wrapper {
padding: @padding;
}
.order-item {
background-color: #fff;
margin-bottom: @padding;
border-radius: 4px;
overflow: hidden;
&:last-child {
margin-bottom: 0;
}
.order-footer {
border-top: 1px solid #f2f2f2;
}
.order-no{
border-bottom: 1px solid #f2f2f2;
padding: 10px;
font-size: 13px;
}
.order-goods-content {
padding: @content_padding;
.info {
display: flex;
}
.goods-name{
flex:1;
margin: 0 8px;
font-size: 15px;
line-height: 1.3;
}
.goods-price{
color:#999;
text-align: right;
}
.sale-price{
color: #333;
}
.origin-price{
text-decoration: line-through;
}
}
.goods-cover-image {
width: 100px;
height: 100px;
}
.price{
text-align: right;
font-size: 13px;
.price-total{
font-size: 16px;
vertical-align: baseline;
}
}
.order-footer {
display: flex;
justify-content: space-between;
padding: @content_padding;
}
.order-status {
display: flex;
align-items: center;
font-size: 14px;
color: #c78a8a;
}
.order-action {
.btn {
margin-left: 10px;
}
}
}

View File

@ -1,181 +0,0 @@
import { cancelOrder, OrderInfo, queryOrderList } from "../../service/shop-api";
import message from "../../utils/message";
type TabType = {
// tab标题
title: string
// 标识
name: string
// 查询状态值
status: number
// 当前查询的页码
page: number
// 是否已经查询结束
end: boolean
// 订单列表
orders: OrderInfo[]
}
function createTab(title: string, name: string, status: number) {
const tab: TabType = {
title,
name,
status,
page: 1,
end: false,
orders: []
}
return tab;
}
// pages/order/index.ts
Page({
/**
*
*/
data: {
tabActive: 'all',
statusEnums: {
1: '待确认',
2: '已确认',
3: '已取消',
4: '已完成',
0: '已删除'
},
tabs: [
createTab('全部', 'all', 0),
createTab('待确认', 'not-confirm', 1),
createTab('已确认', 'confirm', 2),
createTab('已取消', 'cancel', 3),
createTab('已完成', 'finish', 4),
// {
// title: '待确认',
// name: 'not-confirm',
// status: 1,
// orders: []
// },
// {
// title: '已确认',
// name: 'confirm',
// status: 2,
// orders: []
// },
// {
// title: '已取消',
// name: 'cancel',
// status: 3,
// orders: []
// },
// {
// title: '已完成',
// name: 'finish',
// status: 3,
// orders: []
// }
]
},
/**
* --
*/
onLoad() {
this.loadOrderList('all');
},
onTabChange(e: any) {
const tabActive = e.detail.name
// TODO 是否重新加载 -- 缓存
this.loadOrderList(tabActive)
this.setData({ tabActive })
},
showOrderDetail(e: TapEvent){
const id = e.currentTarget.id
wx.navigateTo({
url: `/pages/order/detail?id=${id}`
})
},
async cancelOrder(e: TapEvent) {
try {
if ((await message.confirm('确定要取消订单?'))) {
await cancelOrder(e.target.dataset.id)
message.toast('取消订单成功');
this.loadOrderList(this.data.tabActive)
}
} catch (e) { }
},
async deleteOrder(e: TapEvent) {
try {
if ((await message.confirm('确定要删除订单?'))) {
console.log('shanchu')
await cancelOrder(e.target.dataset.id)
message.toast('取消删除成功');
this.loadOrderList(this.data.tabActive)
}
} catch (e) { }
},
loadOrderList(active: string) {
// 1、找到当前选中的tab
const tab = this.data.tabs.find(s => s.name == active);
if (tab) {
queryOrderList(tab.status).then(ret => {
if (ret.records && ret.records.length > 0) {
if (tab.page === 1) {
tab.orders = ret.records
} else tab.orders.push(...ret.records)
// 更新数据
this.setData({
tabs: this.data.tabs
})
}
})
}
},
/**
* --
*/
onReady() {
},
/**
* --
*/
onShow() {
},
/**
* --
*/
onHide() {
},
/**
* --
*/
onUnload() {
},
/**
* --
*/
onPullDownRefresh() {
},
/**
*
*/
onReachBottom() {
},
/**
*
*/
onShareAppMessage() {
}
})

View File

@ -1,45 +0,0 @@
<!--pages/order/index.wxml-->
<view class="order-page">
<v-tabs sticky swipeable bind:change="onTabChange">
<v-tab wx:for="{{tabs}}" wx:key="name" name="{{item.name}}" title="{{item.title}}">
<view class="order-list-wrapper">
<view wx:for="{{item.orders}}" wx:key="id" class="order-item" wx:for-item="o">
<view class="order-no">
<text>订单编号: </text>
<text>{{o.id}}</text>
</view>
<view class="order-goods-content">
<view class="info" bindtap="showOrderDetail" data-id="{{o.id}}" id="{{o.id}}">
<!-- 商品图片 -->
<view class="goods-cover">
<image class="goods-cover-image" src="{{o.goods.cover}}" />
</view>
<view class="goods-name">
<text>{{o.goods.title}}</text>
</view>
<view class="goods-price">
<view class="sale-price">¥{{o.goods.price}}</view>
<view wx:if="{{o.goods.originPrice > 0}}" class="origin-price">¥{{o.goods.originPrice}}</view>
<view class="count">× 1</view>
</view>
</view>
<view class="price">
<text>合计:</text>
<text class="price-total">{{o.price}}</text>
</view>
</view>
<view class="order-footer">
<view class="order-status">
<text>{{statusEnums[o.status]||''}}</text>
</view>
<view class="order-action">
<v-button wx:if="{{o.status < 3}}" bindtap="cancelOrder" data-id="{{o.id}}" class="btn" round type="default" size="small">取消订单</v-button>
<v-button bindtap="deleteOrder" data-id="{{o.id}}" class="btn" round type="danger" size="small">删除订单</v-button>
</view>
</view>
</view>
</view>
</v-tab>
</v-tabs>
</view>

View File

@ -1,6 +0,0 @@
{
"usingComponents": { },
"navigationBarTitleText": "个人中心",
"navigationBarBackgroundColor": "#ceb17f",
"navigationBarTextStyle": "white"
}

View File

@ -1,33 +0,0 @@
/* pages/personal.wxss */
.grid{
display: grid;
background-color: white;
border-radius: 10px;
padding: 10px;
display: flex;
text-align: center;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
.grid-item{
flex:1;
width: 25%;
}
.icon{
width: 50px;
height: 50px;
line-height: 50px;
border-radius: 50%;
background: linear-gradient(to right,#91b2ff,#136dff);
margin: 10px auto;
}
.iconfont{
font-size: 26px;
color: white;
}
.icon-sign{
background: linear-gradient(to right,#ddba7a,#ff9a31);
}
.item-icon-game{
background: linear-gradient(to right,#ffaf8f,#ff6931);
}
}

View File

@ -1,83 +0,0 @@
// pages/personal.ts
import message from "../../utils/message";
import { getUserProfile, login } from "../../utils/promise-hooks";
import request from "../../utils/request";
const app = getApp<IAppOption>();
Page({
/**
*
*/
data: {
code: '',
userinfo: {}
},
/**
* --
*/
async onLoad() {
if (!app.globalData.token) {
// 发起登录的授权
const code = await login()
this.setData({
code
})
}
},
onShow() {
if (app.globalData.userInfo) {
this.setData({
userinfo: app.globalData.userInfo
})
}
},
async onLogin() {
if (app.globalData.userInfo) return;
// TODO 完成登录
if (!this.data.code) {
this.onLoad()
message.toast('初始化错误,请重新登录')
return;
}
try {
const data = await getUserProfile()
data.code = this.data.code
message.showLoading({ message: '登录中...' })
const res = await request<string>('/user/login', data)
//
console.log(res);
wx.setStorageSync("user-token", res)
app.updateUserInfo().then(userinfo => {
this.setData({
userinfo
})
});
} finally {
message.hideLoading()
}
},
/**
*
*/
onShareAppMessage() {
},
openPage(e: any) {
if(!app.globalData.userInfo){
// 没有登录
return;
}
const dataset = e.currentTarget.dataset
if (dataset.url) {
wx.navigateTo({
url: dataset.url
})
}
}
})

View File

@ -1,55 +0,0 @@
<!--pages/personal.wxml-->
<view class="page-person user-info">
<view class="content-bg"></view>
<view class="content-wrapper">
<view class="header">
<div class="content-container">
<view class="user-info">
<view class="user-avatar-wrapper">
<open-data class="user-avatar" type="userAvatarUrl"></open-data>
</view>
<text class="nickname" bindtap="onLogin">{{userinfo && userinfo.nickname?userinfo.nickname:'请点击登录'}}</text>
</view>
<view class="user-score">
<text>{{userinfo?userinfo.pointInfo.totalPoint:''}}</text>
</view>
</div>
</view>
<view>
<view class="grid">
<view class="grid-item" bindtap="openPage" data-url="/pages/sign/index">
<view class="icon icon-sign">
<text class="iconfont icon-sign-in"></text>
</view>
<view class="text">
<text>签到</text>
</view>
</view>
<view class="grid-item">
<view class="icon icon-history">
<text class="iconfont icon-date"></text>
</view>
<view class="text">
<text>兑换记录</text>
</view>
</view>
<view class="grid-item">
<view class="icon item-icon-game">
<text class="iconfont icon-game"></text>
</view>
<view class="text">
<text>积分游戏</text>
</view>
</view>
<view class="grid-item">
<view class="icon item-icon-collection">
<text class="iconfont icon-gift"></text>
</view>
<view class="text">
<text>我的收藏</text>
</view>
</view>
</view>
</view>
</view>
</view>

View File

@ -1,6 +0,0 @@
{
"usingComponents": {},
"navigationBarTitleText": "每日签到",
"navigationBarBackgroundColor": "#ceb17f",
"navigationBarTextStyle": "white"
}

View File

@ -1,93 +0,0 @@
/* pages/sign/index.less */
.page-sign{
background-color: #efeff4;
.header{
// 签到信息
background-color: #ceb17f;
.sign-info{
margin-left: 10px;
font-size: 14px;
}
.tomorrow{
color: rgba(255, 255, 255, 0.7);
margin-top: 2px;
font-size: 12px;
}
.user-score{
display: flex;
line-height: 30px;
}
.icon-coin{
width: 30px;
height: 30px;
margin-right: 5px;
}
}
.sign-container{
position: relative;
padding: 0px 0 20px;
.bg{
background-color: #ceb17f;
height: 100px;
position: absolute;
left:0;top:0;
right:0;
z-index: 1;
}
}
.sign-content-wrapper{
background-color: white;
padding: 15px;
position: relative;
z-index: 2;
width: 85%;
margin: auto;
border-radius: 20rpx;
}
.title-bar{
color: #333;
font-size: 30rpx;
font-weight: bold;
}
.sign-items{
font-size:10px;
display: flex;
margin-top: 10px;
.item{
flex:1;
margin-right: 10px;
text-align: center;
&:last-child{
margin-right: 0;
}
}
.point{
background-color: #f0f0f0;
padding: 8px 0 6px;
border-radius: 6px;
margin-bottom: 5px;
&.signed{
background-color: #fbe2d8;
color:#ef7e67;
}
}
image{
width: 30px;
height: 30px;
}
}
.btn-sign{
background-color: #ec653c;
color:white;
width: 100%;
margin-top: 20px;
border-radius: 30px;
&[disabled]{
background-color: #ccc;
}
}
}

View File

@ -1,57 +0,0 @@
import message from "../../utils/message"
import { signInfo, sign } from "../../service/user-api"
// 获取应用实例
const app = getApp<IAppOption>();
// pages/sign/index.ts
Page({
/**
*
*/
data: {
pointValue: 0,
signToday: false,
continuousDays: 0,
dayTextArray: [
{ text: '一', value: 5 },
{ text: '二', value: 10 },
{ text: '三', value: 15 },
{ text: '四', value: 20 },
{ text: '五', value: 25 },
{ text: '六', value: 30 },
{ text: '七', value: 35 },
]
},
/**
* --
*/
onLoad() {
if (app.globalData.userInfo) {
if(app.globalData.userInfo.pointInfo){
this.setData({
pointValue: app.globalData.userInfo.pointInfo.totalPoint
})
}
signInfo().then(res => {
this.setData(res)
})
} else {
// 需要登录
message.toast('请先登录')
wx.navigateBack();
}
},
onSignTag() {
message.showLoading({})
sign().then(res => {
app.updateUserInfo();
message.hideLoading()
this.setData(res)
}).catch(err => {
message.hideLoading()
message.toast(err.message)
})
}
})

View File

@ -1,85 +0,0 @@
<!--pages/sign/index.wxml-->
<view class="page-sign user-info">
<view class="header">
<div class="content-container">
<view class="user-info">
<view class="user-avatar-wrapper">
<open-data class="user-avatar" type="userAvatarUrl"></open-data>
</view>
<view class="sign-info">
<view class="text-days">
已连续签到 {{continuousDays}} 天
</view>
<view class="tomorrow">
{{signToday?'明':'今'}}日签到可获得 {{
(continuousDays+1)*5
}} 积分
</view>
</view>
</view>
<view class="user-score">
<image class="icon-coin" src="./../../assets/images/coin.svg"></image>
<text>{{pointValue}}</text>
</view>
</div>
</view>
<view class="sign-container">
<view class="bg"></view>
<view class="sign-content-wrapper ">
<view class="title-bar">
<text>连续签到得积分</text>
</view>
<view class="sign-items">
<view wx:for="{{dayTextArray}}" wx:key="value" class="item">
<view class="point {{index<continuousDays?'signed':''}}">
<view>
<image src="./../../assets/images/coin.svg" alt="" />
</view>
<text>{{item.value}}积分</text>
</view>
<view>
<text>第{{item.text}}天</text>
</view>
</view>
</view>
<!-- disabled="true" -->
<button disabled="{{signToday}}" bindtap="onSignTag" class="btn-sign">立即签到</button>
</view>
</view>
<view class="list">
<view class="list-title">
<text>做任务领积分</text>
</view>
<view class="list-items">
<view class="item">
<view class="icon"></view>
<view class="content">
完善个人资料
</view>
<view class="right">
<button>完成任务</button>
</view>
</view>
<view class="item">
<view class="icon"></view>
<view class="content">
开通VIP会员
</view>
<view class="right">
<button>完成任务</button>
</view>
</view>
<view class="item">
<view class="icon"></view>
<view class="content">
首次兑换商品
</view>
<view class="right">
<button>完成任务</button>
</view>
</view>
</view>
</view>
</view>

View File

@ -1,35 +0,0 @@
interface TapTarget {
id: string,
dataset: {
[key: string]: any
}
}
interface TapEvent {
type: 'tap' | string
target: TapTarget
currentTarget: TapTarget
}
interface PointInfo {
uid: number;
totalPoint: number;
validPoint: number;
expirePoint: number;
expireTime?: any;
updateTime: string;
}
interface UserInfo {
id: number;
openId?: string;
nickname: string;
headImage: string;
gender: number;
province: string;
city: string;
parentId: number;
firstLoginTime: string;
updateTime?: any;
status: number;
token?: string
pointInfo: PointInfo;
}

View File

@ -1,9 +1,6 @@
import message from "../../utils/message" import message from "../../utils/message"
import { getUserProfile, login } from "../../utils/promise-hooks" import { getUserProfile, login } from "../../utils/promise-hooks"
import request, { BizError } from "../../utils/request"; import request, { BizError } from "../../utils/request";
type PageData = {
code: string
}
// pages/user/login.ts // pages/user/login.ts
Page({ Page({
@ -12,42 +9,37 @@ Page({
* *
*/ */
data: { data: {
code:''
}, },
/** /**
* -- * --
*/ */
async onLoad() { async onLoad() {
// 发起登录的授权
const code = await login()
this.setData({
code
})
}, },
async onGetUserInfo() { async onGetUserInfo() {
if(!this.data.code){ message.showLoading()
this.onLoad()
message.toast('初始化错误,请重新登录')
return;
}
message.showLoading({ message: '登录中...' })
try { try {
const data = await getUserProfile() const data = await getUserProfile()
data.code = this.data.code const res = await request('/wechat/login', data)
const res = await request<UserInfo>('/user/login', data) console.log(res)
//
console.log(res);
} finally { } finally {
message.hideLoading() message.hideLoading()
} }
}, },
async getCode() {
try {
const code = await login()
console.log(res)
} catch (e) {
message.toast(e)
}
},
/** /**
* -- * --
*/ */
onReady() { onReady() {
}, },
/** /**

View File

@ -1,59 +0,0 @@
import request, { DataList } from "../utils/request";
export type Goods = {
id: number;
category: number;
type: number;
title: string;
originPrice: number;
price: number;
stock: number;
limitCount: number;
cover: string;
description: string;
notice: string;
onlineTime: string;
offlineTime: string;
createTime: string;
updateTime: string;
status: number;
}
export type OrderInfo = {
id: string;
gid: number;
price: number;
count: number;
uid: number;
data?: any;
createTime?: any;
updateTime?: any;
status: number;
goods?: Goods;
}
export function queryGoodsList(category: number, page = 1, pageSize = 10) {
return request<DataList<Goods>>('/shop/goods/query', {
category,
page,
pageSize
}, 'GET');
}
export function createOrder(goodsId: number, buyCount = 1) {
return request<OrderInfo>('/shop/order/create', {
goodsId, buyCount
});
}
export function queryOrderList(status: number = 0, page = 1, pageSize = 10) {
return request<DataList<OrderInfo>>('/shop/order/query', {
status, page, pageSize
});
}
export function queryOrderDetail(id: string){
return request<OrderInfo>(`/shop/order/${id}`,null,'GET');
}
export function cancelOrder(id: string) {
return request<boolean>(`/shop/order/${id}/cancel`,null,'PUT');
}
export function deleteOrder(id: string) {
return request<boolean>(`/shop/order/${id}/delete`,null,'PUT');
}

View File

@ -1,25 +0,0 @@
import request from "../utils/request";
export type SignInfo = {
signToday: boolean
continuousDays: number
}
/**
*
*/
export function signInfo() {
return request<SignInfo>('/sign/info');
}
/**
*
*/
export function sign() {
return request<SignInfo>('/sign/today');
}
/**
*
*/
export function info(code: string = '', showLogin = true) {
return request<UserInfo>('/user/info', { code }, "GET", showLogin);
}

View File

@ -1,56 +1,28 @@
import { resolve } from "path";
import { BizError } from "./request"; import { BizError } from "./request";
type ToastIcon = 'success' | 'error' | 'none'; type ToastIcon = 'success' | 'error' | 'none';
export function toast(message: string | any, icon: ToastIcon = 'none', callback: (() => void) | null = null) { export function toast(message: string|any, icon: ToastIcon = 'none') {
if (message instanceof BizError) { if(message instanceof BizError){
message = message.message message = message.message
} }
if (callback) {
setTimeout(callback, 2000);
}
return wx.showToast({ return wx.showToast({
title: message, title: message,
duration: 2000, duration: 2000,
icon icon
}) })
} }
export function showLoading({ message = '加载中...', mask = true }={}) { export function showLoading({ message = '加载中...', mask = true }) {
return wx.showLoading({ return wx.showLoading({
title: message, title: message,
mask mask
}) })
} }
export function hideLoading() { export function hideLoading(){
wx.hideLoading() wx.hideLoading()
} }
export function alert(message: string) {
return new Promise((success) => {
wx.showModal({
content: message,
success
})
})
}
export function confirm(message: string) {
return new Promise<boolean>((resolve) => {
wx.showModal({
content: message,
success(res) {
if (res.confirm) {
resolve(true)
} else if (res.cancel) {
resolve(false)
}
}
})
})
}
export default { export default {
toast, toast,
showLoading, showLoading,
hideLoading, hideLoading,
alert,
confirm,
} }

View File

@ -1,7 +1,7 @@
import message from "./message" import message from "./message"
/** /**
* wx.login code * wx.login
* @param timeout * @param timeout
*/ */
export function login(timeout = 10000) { export function login(timeout = 10000) {
@ -35,19 +35,20 @@ type UserProfileData = {
* auth.code2Session * auth.code2Session
* 使 code openidunionidsession_key * 使 code openidunionidsession_key
*/ */
code?: string code: string
} }
export function getUserProfile(timeout = 10000) {
export function getUserProfile() { return new Promise<UserProfileData>((resolve, reject) => {
return new Promise<UserProfileData>(async (resolve, reject) => { login(timeout).then(code => {
// wx.login 必须在获取用户数据之前 wx.getUserProfile({
wx.getUserProfile({ desc: '展示用户信息并参与相关活动',
desc: '展示用户信息并参与相关活动',
success: (res) => { success: (res) => {
console.log(res)
if (res.errMsg == 'getUserProfile:ok' && res.encryptedData) { if (res.errMsg == 'getUserProfile:ok' && res.encryptedData) {
resolve({ resolve({
encryptedData: res.encryptedData, encryptedData: res.encryptedData,
iv: res.iv iv: res.iv,
code
}) })
} else { } else {
message.toast('登录失败,请重新登录', 'error') message.toast('登录失败,请重新登录', 'error')
@ -59,6 +60,6 @@ export function getUserProfile() {
reject('登录失败,' + e.errMsg) reject('登录失败,' + e.errMsg)
} }
}) })
}).catch(reject)
}); });
} }

View File

@ -8,18 +8,6 @@ export class BizError extends Error {
this.code = code; this.code = code;
} }
} }
export type DataList<T> = {
records: T[];
total: number;
size: number;
current: number;
orders: any[];
optimizeCountSql: boolean;
searchCount: boolean;
countId?: any;
maxLimit?: any;
pages: number;
}
type ApiResponse<T> = { type ApiResponse<T> = {
code: 0 | number code: 0 | number
message: string message: string
@ -27,21 +15,20 @@ type ApiResponse<T> = {
} }
type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" type HttpMethod = "GET" | "POST" | "PUT" | "DELETE"
function request<T>(api: string, data: any = null, method: HttpMethod = 'POST', autoShowLogin: boolean = true) { function request<T>(api: string, data: any = null, method: HttpMethod = 'POST') {
const header: { const header: {
[key: string]: string [key: string]: string
} = {} } = {}
const app = getApp();
// 判断是否有token // 判断是否有token
const token = app ? app.globalData.token : wx.getStorageSync('user-token') const token = getApp().globalData.token
if (token) { // 如果有token 添加token头 if (token) { // 如果有token 添加token头
header.token = token header.token = token
} }
// 对于post请求发送json数据 // 对于post请求发送json数据
if (method !== 'POST') { if (method === 'POST') {
header['content-type'] = 'application/json' header['content-type'] = 'application/json'
} }
return new Promise<T>((resolve, reject) => { return new Promise((resolve, reject) => {
wx.request<ApiResponse<T>>({ wx.request<ApiResponse<T>>({
url: config.api_url + api, url: config.api_url + api,
data, data,
@ -53,24 +40,16 @@ function request<T>(api: string, data: any = null, method: HttpMethod = 'POST',
reject(new BizError('请求数据失败(server)', -1)) reject(new BizError('请求数据失败(server)', -1))
return; return;
} }
if (!res.data) { if(!res.data){
reject(new BizError('请求数据失败(empty)', -1)) reject(new BizError('请求数据失败(empty)', -1))
return; return;
} }
// 获取响应数据
const result = res.data const result = res.data
// 验证接口是否正确 // 验证接口是否正确
if (result.code !== 0) { if (result.code !== 0) {
if (result.code === 403 && autoShowLogin) {
wx.switchTab({
url: '/pages/personal/personal'
})
return;
}
reject(new BizError(result.message, result.code)) reject(new BizError(result.message, result.code))
return; return;
} }
// 请求成功 直接回调
resolve(result.data) resolve(result.data)
}, },
fail: (e) => { fail: (e) => {

27
package-lock.json generated
View File

@ -7,12 +7,9 @@
"": { "": {
"name": "miniprogram-ts-less-quickstart", "name": "miniprogram-ts-less-quickstart",
"version": "1.0.0", "version": "1.0.0",
"dependencies": {
"@vant/weapp": "^1.10.8"
},
"devDependencies": { "devDependencies": {
"@types/node": "^18.11.9", "@types/node": "^18.11.9",
"miniprogram-api-typings": "^3.6.0" "miniprogram-api-typings": "^2.12.0"
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
@ -21,15 +18,10 @@
"integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==", "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==",
"dev": true "dev": true
}, },
"node_modules/@vant/weapp": {
"version": "1.10.8",
"resolved": "https://registry.npmmirror.com/@vant/weapp/-/weapp-1.10.8.tgz",
"integrity": "sha512-/6w9U5UclF50ORqM2C9vo+oB5+PCOuLGpNI3cxYL1z0xWqPYratitLRhQx53Qo6k1I45Ri8DYGCb7C0qSKB/xg=="
},
"node_modules/miniprogram-api-typings": { "node_modules/miniprogram-api-typings": {
"version": "3.6.0", "version": "2.12.0",
"resolved": "https://registry.npmmirror.com/miniprogram-api-typings/-/miniprogram-api-typings-3.6.0.tgz", "resolved": "https://registry.npmmirror.com/miniprogram-api-typings/-/miniprogram-api-typings-2.12.0.tgz",
"integrity": "sha512-xwK3PzhhxnfWqDfBikHLdAbj7Wy4F887nBcQrzwuF758Fw2qC4ivpKPL9t0uJZk5QYnU28+NqA7Q3lzYGMHQnA==", "integrity": "sha512-ibvbqeslVFur0IAvTxLMvsbtvVcMo6gwvOnj0YZHV7aeDLu091VQRrETT2QuiG9P6aZWRcxeNGJChRKVPCp9VQ==",
"dev": true "dev": true
} }
}, },
@ -40,15 +32,10 @@
"integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==", "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==",
"dev": true "dev": true
}, },
"@vant/weapp": {
"version": "1.10.8",
"resolved": "https://registry.npmmirror.com/@vant/weapp/-/weapp-1.10.8.tgz",
"integrity": "sha512-/6w9U5UclF50ORqM2C9vo+oB5+PCOuLGpNI3cxYL1z0xWqPYratitLRhQx53Qo6k1I45Ri8DYGCb7C0qSKB/xg=="
},
"miniprogram-api-typings": { "miniprogram-api-typings": {
"version": "3.6.0", "version": "2.12.0",
"resolved": "https://registry.npmmirror.com/miniprogram-api-typings/-/miniprogram-api-typings-3.6.0.tgz", "resolved": "https://registry.npmmirror.com/miniprogram-api-typings/-/miniprogram-api-typings-2.12.0.tgz",
"integrity": "sha512-xwK3PzhhxnfWqDfBikHLdAbj7Wy4F887nBcQrzwuF758Fw2qC4ivpKPL9t0uJZk5QYnU28+NqA7Q3lzYGMHQnA==", "integrity": "sha512-ibvbqeslVFur0IAvTxLMvsbtvVcMo6gwvOnj0YZHV7aeDLu091VQRrETT2QuiG9P6aZWRcxeNGJChRKVPCp9VQ==",
"dev": true "dev": true
} }
} }

View File

@ -9,8 +9,5 @@
"devDependencies": { "devDependencies": {
"@types/node": "^18.11.9", "@types/node": "^18.11.9",
"miniprogram-api-typings": "^3.6.0" "miniprogram-api-typings": "^3.6.0"
},
"dependencies": {
"@vant/weapp": "^1.10.8"
} }
} }

View File

@ -9,23 +9,13 @@
"projectname": "ts-demo", "projectname": "ts-demo",
"setting": { "setting": {
"useCompilerPlugins": [ "useCompilerPlugins": [
"typescript", "typescript"
"less"
], ],
"babelSetting": { "babelSetting": {
"ignore": [], "ignore": [],
"disablePlugins": [], "disablePlugins": [],
"outputPath": "" "outputPath": ""
}, }
"minified": true,
"ignoreUploadUnusedFiles": true,
"packNpmManually": true,
"packNpmRelationList": [
{
"packageJsonPath": "./package.json",
"miniprogramNpmDistDir": "./miniprogram/"
}
]
}, },
"simulatorType": "wechat", "simulatorType": "wechat",
"simulatorPluginLibVersion": {}, "simulatorPluginLibVersion": {},

View File

@ -1,9 +1,8 @@
{ {
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "point_sys_miniapp", "projectname": "userlogin-demo",
"setting": { "setting": {
"compileHotReLoad": true, "compileHotReLoad": true,
"urlCheck": false, "urlCheck": false
"bigPackageSizeSupport": true
} }
} }

4
typings/index.d.ts vendored
View File

@ -2,10 +2,8 @@
interface IAppOption { interface IAppOption {
globalData: { globalData: {
userInfo?: UserInfo, userInfo?: WechatMiniprogram.UserInfo,
token?: string token?: string
} }
userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback, userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback,
updateUserInfo: () => Promise<UserInfo>
initLoginInfo: (resolve: (value: any) => void, reject: (reason: any) => void) => void
} }

View File

@ -1,18 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/node@^18.11.9":
version "18.14.0"
resolved "https://registry.npmmirror.com/@types/node/-/node-18.14.0.tgz#94c47b9217bbac49d4a67a967fdcdeed89ebb7d0"
integrity sha512-5EWrvLmglK+imbCJY0+INViFWUHg1AHel1sq4ZVSfdcNqGy9Edv3UB9IIzzg+xPaUcAgZYcfVs2fBcwDeZzU0A==
"@vant/weapp@^1.10.8":
version "1.10.13"
resolved "https://registry.npmmirror.com/@vant/weapp/-/weapp-1.10.13.tgz#795c52b4e5a757ad02091df2c9910e63daabffe6"
integrity sha512-Ps56qHY60W0QpaFKgzN2UGWfzCcKfZrM7QZVfFM3Qx9Kpm/Tnqln+mrGSMiI84+6qU0Bv1xKX6FBDa04yNiwAQ==
miniprogram-api-typings@^3.6.0:
version "3.9.0"
resolved "https://registry.npmmirror.com/miniprogram-api-typings/-/miniprogram-api-typings-3.9.0.tgz#c04a6b7eae5585733b5f8787297f2b9f1b60abac"
integrity sha512-QCXHHW9H4XYazb8J9EMiFyaOWHXhBG4oehkQqi+76FJpKKIlpgL0ZkXxzJ2L+6T/c5OxKm7iegovKIQGVkZDLQ==