Skip to content

Commit

Permalink
增加动态会员码功能
Browse files Browse the repository at this point in the history
  • Loading branch information
woniudiancang committed Feb 16, 2023
1 parent 65acd4c commit a12ec8d
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 13 deletions.
1 change: 1 addition & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"pages/all-orders/index",
"pages/my/index",
"pages/my/feedback",
"pages/my/user-code",
"pages/ad/index",
"pages/pay/index",
"pages/shop/select",
Expand Down
4 changes: 2 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
version: "4.2.1",
note: 'fix:加入购物车minBuyNumber导致的数量bug',
version: "4.3.0",
note: '增加动态会员码功能',
subDomain: "beeorder", // 根据教程 https://www.it120.cc/help/qr6l4m.html 查看并设置你自己的 subDomain
baiduMapKey: "TJ3BZ-6LVCF-C25JP-JOA3O-EWZFJ-5FBMI", // 百度地图开放平台去申请自己的key,用来计算配送距离
}
6 changes: 6 additions & 0 deletions miniprogram_npm/apifm-wxapi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,12 @@ module.exports = {
loginout: function loginout(token) {
return request('/user/loginout', true, 'get', { token: token });
},
userDelete: (token) => {
return request('/user/delete', true, 'post', { token })
},
dynamicUserCode: (token) => {
return request('/user/dynamicUserCode', true, 'get', { token })
},
userLevelList: function userLevelList(data) {
return request('/user/level/list', true, 'post', data);
},
Expand Down
7 changes: 6 additions & 1 deletion pages/my/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,10 @@ Page({
title: '设置成功',
})
this.getUserApiInfo()
}
},
goUserCode() {
wx.navigateTo({
url: '/pages/my/user-code',
})
},
})
23 changes: 14 additions & 9 deletions pages/my/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
<image mode='aspectFill' class='background' src='{{myBg}}'></image>
<view class="my-box">
<view class="head-bar">
<!-- <image src="/images/default.png" mode="aspectFill" class="userinfo-avatar"></image> -->
<button class="userinfo-avatar" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
<image src="{{ apiUserInfoMap.base.avatarUrl ? apiUserInfoMap.base.avatarUrl : '/images/default.png' }}" mode="aspectFill" class="userinfo-avatar-img"></image>
</button>
<view class="name-box">
<view class="name" bindtap="editNick">{{ nick ? nick : '点击设置昵称' }}</view>
<view wx:if="{{apiUserInfoMap.userLevel}}" class="state" bindtap="govip">{{apiUserInfoMap.userLevel.name}}</view>
<view wx:else class="state" bindtap="govip">非会员</view>
</view>
<view class="head-bar-left">
<button class="userinfo-avatar" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
<image src="{{ apiUserInfoMap.base.avatarUrl ? apiUserInfoMap.base.avatarUrl : '/images/default.png' }}" mode="aspectFill" class="userinfo-avatar-img"></image>
</button>
<view class="name-box">
<view class="name" bindtap="editNick">{{ nick ? nick : '点击设置昵称' }}</view>
<view wx:if="{{apiUserInfoMap.userLevel}}" class="state" bindtap="govip">{{apiUserInfoMap.userLevel.name}}</view>
<view wx:else class="state" bindtap="govip">非会员</view>
</view>
</view>
<view class="user-code" bindtap="goUserCode">
<van-icon name="qr" size="64rpx" />
<view class="txt">会员码</view>
</view>
</view>
<view wx:if="{{apiUserInfoMap}}" class="coupon-box">
<view class="coupon" bindtap="goCoupons">
Expand Down
17 changes: 17 additions & 0 deletions pages/my/index.wxss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
.my-box .head-bar{
display: flex;
align-items: center;
justify-content: space-between;
padding-right: 32rpx;
}
.head-bar-left {
display: flex;
align-items: center;
}
.my-box .head-bar .head{
height: 120rpx;
Expand All @@ -93,6 +99,17 @@
line-height: 40rpx;
border-radius: 20rpx;
}
.user-code {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.user-code .txt {
font-size: 24rpx;
color: #333;
}

.coupon-box{
display: flex;
justify-content: center;
Expand Down
39 changes: 39 additions & 0 deletions pages/my/user-code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const WXAPI = require('apifm-wxapi')
import wxbarcode from 'wxbarcode'

Page({
data: {
balance: 0,
freeze: 0,
score: 0,
growth: 0,
userCode: undefined
},
onLoad(e) {
this.getUserAmount()
this.dynamicUserCode()
},
onShow: function () {
},
async getUserAmount() {
const res = await WXAPI.userAmount(wx.getStorageSync('token'))
if (res.code == 0) {
this.setData({
balance: res.data.balance,
freeze: res.data.freeze,
score: res.data.score,
growth: res.data.growth
})
}
},
async dynamicUserCode() {
const res = await WXAPI.dynamicUserCode(wx.getStorageSync('token'))
if (res.code == 0) {
this.setData({
userCode: res.data
})
wxbarcode.barcode('barcode', res.data, 650, 200);
wxbarcode.qrcode('qrcode', res.data, 650, 650);
}
},
})
3 changes: 3 additions & 0 deletions pages/my/user-code.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "会员码"
}
8 changes: 8 additions & 0 deletions pages/my/user-code.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

<view class="title">{{ userCode }}</view>
<canvas class="user-code-bar" canvas-id="barcode" />
<canvas class="user-code" canvas-id="qrcode" />
<van-grid column-num="2" icon-size="64rpx" square>
<van-grid-item icon="balance-o" text="余额 {{ balance }}" icon-color="#e64340" text-class="amount-c" />
<van-grid-item icon="points" text="积分 {{ score }}" icon-color="#e64340" text-class="amount-c" />
</van-grid>
22 changes: 22 additions & 0 deletions pages/my/user-code.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.title {
text-align: center;
color: #666;
margin: 32rpx;
}

.van-grid-item__text {
color: #e64340 !important;
font-size: 28rpx !important;
}

.user-code-bar {
width: 650rpx;
height: 200rpx;
margin-left: 50rpx;
}

.user-code {
width: 650rpx;
height: 650rpx;
margin-left: 50rpx;
}
9 changes: 8 additions & 1 deletion project.private.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,18 @@
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/my/index",
"query": "",
"launchMode": "default",
"scene": null
}
]
}
},
"projectname": "%E5%B0%8F%E8%9C%9C%E8%9C%82%E7%82%B9%E9%A4%90",
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"libVersion": "2.28.0"
"libVersion": "2.30.0"
}

0 comments on commit a12ec8d

Please sign in to comment.