├── README.md ├── app.js ├── app.json ├── app.wxss ├── components ├── Coupon │ ├── Coupon.js │ ├── Coupon.json │ ├── Coupon.wxml │ └── Coupon.wxss ├── GetCard │ ├── GetCard.js │ ├── GetCard.json │ ├── GetCard.wxml │ └── GetCard.wxss └── List │ ├── List.js │ ├── List.json │ ├── List.wxml │ ├── List.wxss │ ├── ListItem.js │ ├── ListItem.json │ ├── ListItem.wxml │ └── ListItem.wxss ├── pages ├── activity │ ├── activity.js │ ├── activity.json │ ├── activity.wxml │ └── activity.wxss ├── card │ ├── cardDetail.js │ ├── cardDetail.json │ ├── cardDetail.wxml │ ├── cardDetail.wxss │ ├── cardIndex.js │ ├── cardIndex.json │ ├── cardIndex.wxml │ ├── cardIndex.wxss │ ├── cardIndexNewUsr.js │ ├── cardIndexNewUsr.json │ ├── cardIndexNewUsr.wxml │ └── cardIndexNewUsr.wxss ├── coupons │ ├── couponList.js │ ├── couponList.json │ ├── couponList.wxml │ ├── couponList.wxss │ ├── couponListViewOnly.js │ ├── couponListViewOnly.json │ ├── couponListViewOnly.wxml │ └── couponListViewOnly.wxss ├── help │ ├── eGuide.js │ ├── eGuide.json │ ├── eGuide.wxml │ ├── eGuide.wxss │ ├── help.js │ ├── help.json │ ├── help.wxml │ └── help.wxss ├── index │ ├── index.js │ ├── index.json │ ├── index.wxml │ └── index.wxss ├── memberShip │ ├── myVip.js │ ├── myVip.json │ ├── myVip.wxml │ └── myVip.wxss ├── records │ ├── pointsList.js │ ├── pointsList.json │ ├── pointsList.wxml │ ├── pointsList.wxss │ ├── transactionDetail.js │ ├── transactionDetail.json │ ├── transactionDetail.wxml │ ├── transactionDetail.wxss │ ├── transactionList.js │ ├── transactionList.json │ ├── transactionList.wxml │ └── transactionList.wxss ├── redirect │ ├── redirect.js │ ├── redirect.json │ └── redirect.wxml └── topup │ ├── pay.js │ ├── pay.json │ ├── pay.wxml │ ├── pay.wxss │ ├── topup.js │ ├── topup.json │ ├── topup.wxml │ ├── topup.wxss │ ├── topupDiscounts.js │ ├── topupDiscounts.json │ ├── topupDiscounts.wxml │ ├── topupDiscounts.wxss │ ├── topupResult.js │ ├── topupResult.json │ ├── topupResult.wxml │ └── topupResult.wxss ├── project.config.json ├── resource └── image │ ├── activity-bg.png │ ├── advertisement-bg.png │ ├── arrow_rgt.png │ ├── arrow_right.png │ ├── barcode.png │ ├── card.png │ ├── card1.png │ ├── card2.png │ ├── card3.png │ ├── card_black.png │ ├── card_img.png │ ├── card_red.png │ ├── card_yellow.png │ ├── check-box.png │ ├── check_on.png │ ├── checked.png │ ├── coupon_no.png │ ├── coupon_on.png │ ├── customer1.png │ ├── customer2.png │ ├── customer_logo1.png │ ├── customer_logo2.png │ ├── discount.png │ ├── give.png │ ├── guide-red.png │ ├── member_card_banner.png │ ├── open.png │ ├── qrcode.png │ ├── recharge-success.png │ ├── reduction.png │ ├── refresh.png │ ├── service_ico1.png │ ├── service_ico2.png │ ├── service_ico3.png │ ├── service_ico4.png │ ├── switch-off.png │ └── switch-on.png ├── screens ├── 1.jpg ├── 2.jpg ├── 3.jpg ├── 4.jpg └── 5.jpg └── utils ├── barcode.js ├── code.js ├── eventProxy.js ├── qrcode.js └── util.js /README.md: -------------------------------------------------------------------------------- 1 | # wxClubCard 2 | 微信小程序,会员卡商城,购买某个商店的会员卡,可以领取到个人的微信卡包,有权益、充值、交易记录、优惠券、积分记录页面 3 | 4 | # 注意事项 5 | 1、需要自行修改project.config.json文件中的"appid"值。 6 | 7 | ![image](https://github.com/panyefan/wxClubCard/blob/master/screens/1.jpg) 8 | ![image](https://github.com/panyefan/wxClubCard/blob/master/screens/2.jpg) 9 | ![image](https://github.com/panyefan/wxClubCard/blob/master/screens/3.jpg) 10 | ![image](https://github.com/panyefan/wxClubCard/blob/master/screens/4.jpg) 11 | ![image](https://github.com/panyefan/wxClubCard/blob/master/screens/5.jpg) 12 | 13 | 14 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | //app.js 2 | App({ 3 | onLaunch: function () { 4 | console.log('onLaunch'); 5 | wx.clearStorageSync(); 6 | }, 7 | onShow: function () { 8 | // Do something when show. 9 | console.log('onShow'); 10 | }, 11 | onHide: function () { 12 | // Do something when hide. 13 | console.log('onHide'); 14 | }, 15 | onError: function (msg) { 16 | console.log('onError'); 17 | }, 18 | login: function (cb, options) { 19 | options = options || {}; 20 | var that = this; 21 | wx.login({ 22 | success: function (wxloginres) { 23 | if (wxloginres.code) { 24 | wx.getUserInfo({ 25 | withCredentials: true, 26 | success: function (wxgetuserres) { 27 | // 将key和用户绑定 28 | wx.request({ 29 | url: that.globalData.apiurl + '/login', 30 | method: 'POST', 31 | header: { 32 | 'content-type': 'application/json' 33 | }, 34 | data: { 35 | code: wxloginres.code, 36 | rawData: wxgetuserres.rawData, 37 | signature: wxgetuserres.signature, 38 | encryptedData: wxgetuserres.encryptedData, 39 | iv: wxgetuserres.iv 40 | }, 41 | success: function (syncres) { 42 | if (!that.isSuccess(syncres.data) || syncres.statusCode !== 200) { 43 | var flag = false; 44 | if (typeof options.complete === 'function') { 45 | flag = options.complete(syncres, 'wxsyncuser'); 46 | } 47 | 48 | if(!flag){ 49 | that.parseError(syncres.data); 50 | } 51 | return; 52 | } 53 | wx.setStorageSync('sessionid', syncres.data.data && syncres.data.data.sessionId); 54 | typeof cb === "function" && cb(syncres.data.data && syncres.data.data.user); 55 | }, 56 | fail: function () { 57 | 58 | }, 59 | complete: function (syncres) { 60 | if (syncres.statusCode !== 200) { 61 | var flag = false; 62 | if (typeof options.complete === 'function') { 63 | flag = options.complete(syncres, 'wxsyncuser'); 64 | } 65 | if(!flag){ 66 | wx.showModal({ 67 | title: '出错了', 68 | content: '服务器繁忙,请稍后重试', 69 | showCancel: false 70 | }); 71 | } 72 | } 73 | } 74 | }); 75 | }, 76 | fail: function (wxgetuserres) { 77 | var flag = false; 78 | if (typeof options.complete === 'function') { 79 | flag = options.complete(wxgetuserres, 'wxgetuser'); 80 | } 81 | 82 | if(!flag){ 83 | wx.showModal({ 84 | title: '出错了', 85 | content: '获取用户信息失败', 86 | showCancel: false 87 | }); 88 | } 89 | }, 90 | complete: function (res) { 91 | 92 | } 93 | }); 94 | } else { 95 | console.log('获取用户登录态code失败:' + wxloginres); 96 | var flag = false; 97 | if (typeof options.complete === 'function') { 98 | flag = options.complete(wxloginres, 'wxlogincode'); 99 | } 100 | 101 | if(!flag){ 102 | wx.showModal({ 103 | title: '出错了', 104 | content: '获取用户信息失败', 105 | showCancel: false 106 | }); 107 | } 108 | } 109 | }, 110 | fail: function (wxloginfail) { 111 | var flag = false; 112 | if (typeof options.complete === 'function') { 113 | flag = options.complete(wxloginfail, 'wxlogin'); 114 | } 115 | 116 | if(!flag){ 117 | wx.showModal({ 118 | title: '出错了', 119 | content: '获取用户信息失败', 120 | showCancel: false 121 | }); 122 | } 123 | } 124 | }); 125 | }, 126 | auth : function (cb) { 127 | wx.getSetting({ 128 | success(res) { 129 | if (!res.authSetting['scope.userInfo']) { 130 | wx.authorize({ 131 | scope: 'scope.userInfo', 132 | success() { 133 | cb(); 134 | }, 135 | fail() { 136 | wx.openSetting({ 137 | success: (authSetting) => { 138 | console.log(authSetting) 139 | }, 140 | fail:function () { 141 | 142 | } 143 | }) 144 | } 145 | }); 146 | } else { 147 | cb(); 148 | } 149 | } 150 | }); 151 | }, 152 | 153 | request: function (options, notretry, noCheckAuth, noCheckSession) { 154 | var that = this; 155 | if(!noCheckAuth) { 156 | this.auth(function () { 157 | that.request(options, false, true, false); 158 | }); 159 | } else if(!noCheckSession) { 160 | wx.checkSession({ 161 | success: function () { 162 | that.request(options, false, true, true); 163 | }, 164 | fail: function () { 165 | wx.removeStorageSync('sessionid'); 166 | that.request(options, false, true, true); 167 | } 168 | }); 169 | } else { 170 | var sessionId = wx.getStorageSync('sessionid'); 171 | if (!sessionId) { 172 | that.login(function () { 173 | that.request(options, false, true, true); 174 | }, options); 175 | return; 176 | } else { 177 | var data = options.data || {}; 178 | var apiurl = options.apiurl || that.globalData.apiurl; 179 | var header = options.header || {}; 180 | header['content-type'] = header['content-type'] || 'application/json'; 181 | 182 | data.sessionId = sessionId; 183 | wx.request({ 184 | url: apiurl + options.url, 185 | method: options.method || 'POST', 186 | header: header, 187 | data: data, 188 | success: function (res) { 189 | if (res.data && !res.data.data && !res.data.status && res.data.error && res.data.error.code === 'common.not.login' && !notretry) { 190 | that.login(function () { 191 | that.request(options, true, true, true); 192 | }, options); 193 | return; 194 | } 195 | 196 | if (!that.isSuccess(res.data) || res.statusCode !== 200) { 197 | if(typeof options.fail === 'function'){ 198 | options.fail(res); 199 | } else { 200 | that.parseError(res.data); 201 | } 202 | return; 203 | } 204 | 205 | typeof options.success === 'function' && options.success(res); 206 | }, 207 | dataType: options.dataType || 'json', 208 | fail: function (res) { 209 | if (typeof options.fail === 'function') { 210 | options.fail(res); 211 | } else { 212 | wx.showModal({ 213 | title: '出错了', 214 | content: '服务器繁忙,请稍后重试', 215 | showCancel: false 216 | }); 217 | } 218 | }, 219 | complete: function (res) { 220 | var flag = false; 221 | if (typeof options.complete === 'function') { 222 | flag = options.complete(res, 'request'); 223 | } 224 | 225 | if(!flag){ 226 | if (res.statusCode !== 200) { 227 | wx.showModal({ 228 | title: '出错了', 229 | content: '服务器繁忙,请稍后重试', 230 | showCancel: false 231 | }); 232 | } 233 | } 234 | } 235 | }); 236 | } 237 | } 238 | }, 239 | globalData: { 240 | // apiurl: 'https://d4.infix.siemin.com/wxapp' 241 | // apiurl: 'https://testapp.test.siemin.com/wxapp' 242 | apiurl: 'https://eppc.siemin.com/wxapp' 243 | }, 244 | isSuccess: function (result) { 245 | return !result || (typeof result.status === 'undefined' || result.status); 246 | }, 247 | parseError: function (result) { 248 | if (result && typeof result.status !== 'undefined' && !result.status) { 249 | wx.showModal({ 250 | title: '出错了', 251 | content: result.error.message || '服务器繁忙,请稍后重试', 252 | showCancel: false 253 | }); 254 | } 255 | } 256 | }) -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/card/cardIndex", 4 | "pages/topup/topupDiscounts", 5 | "pages/topup/topupResult", 6 | "pages/card/cardIndexNewUsr", 7 | "pages/card/cardDetail", 8 | "pages/coupons/couponList", 9 | "pages/coupons/couponListViewOnly", 10 | "pages/topup/topup", 11 | "pages/activity/activity", 12 | "pages/memberShip/myVip", 13 | "pages/records/transactionList", 14 | "pages/records/transactionDetail", 15 | "pages/records/pointsList", 16 | "pages/topup/pay", 17 | "pages/help/help", 18 | "pages/help/eGuide", 19 | "pages/redirect/redirect", 20 | "pages/index/index" 21 | ], 22 | "window": { 23 | "backgroundTextStyle": "light", 24 | "navigationBarBackgroundColor": "#fff", 25 | "navigationBarTitleText": "旺旺会员卡", 26 | "navigationBarTextStyle": "black" 27 | } 28 | } -------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- 1 | /**app.wxss**/ 2 | .container { 3 | height: 100%; 4 | display: flex; 5 | flex-direction: column; 6 | align-items: center; 7 | justify-content: space-between; 8 | padding: 200rpx 0; 9 | box-sizing: border-box; 10 | } 11 | page{background:#F4F4F4;font-family: PingFangSC-Regular;} 12 | 13 | .swift_button_wrap{position:absolute;bottom:60rpx;left:0;right:0;padding:0 30rpx;} 14 | .swift_button{ 15 | background: url(data:image/png;base64,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); 16 | background-size: 100% 100%; 17 | color:#ffffff;font-size:36rpx;border-radius:10rpx;height:100rpx;line-height:100rpx;} 18 | .swift_button.size_small{height:68rpx;line-height: 68rpx;font-size:28rpx;} 19 | .swift_button_hover{opacity:0.95;} 20 | .swift_button.roud{border-radius:100rpx;} -------------------------------------------------------------------------------- /components/Coupon/Coupon.js: -------------------------------------------------------------------------------- 1 | // components/Coupon/Coupon.js 2 | var Proxy = require('../../utils/eventProxy.js'); 3 | Component({ 4 | /** 5 | * 组件的属性列表 6 | */ 7 | properties: { 8 | key: { // 组件标识码,唯一时,用于标识优惠只能选中其中一个,不唯一(或没有传值进来),可多选 9 | type: String, 10 | value: '-1' 11 | }, 12 | disabled: { // 是否禁用 13 | type: Boolean, 14 | value: false 15 | }, 16 | isShowCheck: { // 默认显示勾选按钮图标 17 | type: Boolean, 18 | value: true 19 | }, 20 | isCheck: { // 优惠券被是否选中 21 | type: Boolean, 22 | value: false, 23 | observer: function (newData, oldData) { 24 | this.data.isCheck = newData; 25 | } 26 | }, 27 | couponColor: { // 优惠券颜色 28 | type: String, 29 | value: 'red' 30 | }, 31 | info: { // 信息数据 32 | type: Object, 33 | value: { 34 | 'couponName': '代金券', 35 | 'typeName': '优惠券', 36 | 'useCondition': '使用条件', 37 | 'startDate': '2018.01.02', 38 | 'endDate': '2018.03-06', 39 | 'rightMoney': '10', 40 | 'rightMoneyUnit': '元', 41 | } 42 | }, 43 | }, 44 | 45 | /** 46 | * 组件的初始数据 47 | */ 48 | data: { 49 | isCheck: false // 优惠券被是否选中 50 | }, 51 | 52 | // 生命周期函数 53 | ready: function () { 54 | // 监听者 55 | Proxy.eventProxy.on('coupon_module', (msg) => { 56 | // 将其他被选中的优惠券重置掉 57 | if (this.data.isCheck && msg !== this.properties.key) { 58 | this.setData({ 59 | isCheck: false 60 | }); 61 | } 62 | }) 63 | }, 64 | 65 | /** 66 | * 组件的方法列表 67 | */ 68 | methods: { 69 | _selectCouponEvent() { 70 | var obj = this.properties.info; 71 | var isCheckFlag = !this.data.isCheck; 72 | if(this.properties.isShowCheck){ 73 | this.setData({ 74 | isCheck: isCheckFlag 75 | }); 76 | } 77 | obj.isCheck = isCheckFlag; 78 | 79 | if (isCheckFlag) { 80 | // 发布者 81 | Proxy.eventProxy.trigger('coupon_module', this.properties.key); 82 | } 83 | 84 | var myEventDetail = obj; // detail对象,提供给事件监听函数 85 | var myEventOption = {}; // 触发事件的选项 86 | this.triggerEvent('selectCouponEvent', myEventDetail, myEventOption); 87 | } 88 | } 89 | }) 90 | -------------------------------------------------------------------------------- /components/Coupon/Coupon.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /components/Coupon/Coupon.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{info.couponName}} 8 | {{info.typeName}} 9 | 10 | 使用条件:{{info.useCondition||''}} 11 | {{info.startDate}}-{{info.endDate}} 12 | 13 | 14 | 15 | 16 | {{info.rightMoney}}{{info.rightMoneyUnit}} 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /components/Coupon/Coupon.wxss: -------------------------------------------------------------------------------- 1 | /* components/Coupon/Coupon.wxss */ 2 | .wrapper { 3 | position: relative; 4 | width: 100%; 5 | height: 210rpx; 6 | border-radius: 14rpx; 7 | } 8 | 9 | .coupon-background-red{ 10 | background-image: linear-gradient(-88deg, #FA8BA7 0%, #FB8989 100%); 11 | } 12 | .coupon-background-blue{ 13 | background-image: linear-gradient(-88deg, #899CF8 0%, #C8A8FB 100%); 14 | } 15 | .coupon-background-indigo{ 16 | background-image: linear-gradient(-88deg, #15C5BE 0%, #77C1E9 100%); 17 | } 18 | .coupon-background-yellow{ 19 | background-image: linear-gradient(-88deg, #CEF78B 0%, #E5FAAA 100%); 20 | } 21 | .coupon-background-disabled{ 22 | background: #C8C7C7; 23 | } 24 | 25 | .wrapper .disabled{ 26 | position: absolute; 27 | top: 0; 28 | left: 0; 29 | bottom: 0; 30 | right: 0; 31 | background: rgba(255, 255, 255, 0.6); 32 | z-index: 1; 33 | } 34 | 35 | .wrapper .coupon { 36 | position: relative; 37 | display: flex; 38 | color: #fff; 39 | } 40 | .wrapper .coupon .content { 41 | flex: 1; 42 | padding: 28rpx 30rpx; 43 | } 44 | 45 | .wrapper .coupon .content .desc { 46 | display: block; 47 | width:398rpx; 48 | white-space: nowrap; 49 | text-overflow: ellipsis; 50 | overflow: hidden; 51 | opacity: 0.8; 52 | font-size: 24rpx; 53 | letter-spacing: 1rpx; 54 | margin-bottom: 8rpx; 55 | } 56 | 57 | .wrapper .coupon .content .title{ 58 | margin-bottom: 23rpx; 59 | } 60 | .wrapper .coupon .content .title .text{ 61 | display: inline-block; 62 | font-size: 42rpx; 63 | line-height: 42rpx; 64 | letter-spacing: 1.75rpx; 65 | margin-right: 14rpx; 66 | vertical-align: middle; 67 | } 68 | .wrapper .coupon .content .title .btn{ 69 | display: inline-block; 70 | border: 1rpx solid #fff; 71 | border-radius: 100rpx; 72 | padding: 4rpx 16rpx; 73 | font-size: 25rpx; 74 | line-height: 25rpx; 75 | } 76 | 77 | .time { 78 | display: block; 79 | opacity: 0.8; 80 | font-size: 24rpx; 81 | letter-spacing: 1rpx; 82 | } 83 | 84 | .tip { 85 | position: relative; 86 | flex: 0 0 183rpx; 87 | text-align: center; 88 | padding-right: 18rpx; 89 | } 90 | 91 | .split-line { 92 | height: 210rpx; 93 | position: relative; 94 | flex: 0 0 0; 95 | border-left: 2rpx dashed #fff; 96 | margin: 0 10rpx; 97 | } 98 | 99 | .split-line:before, 100 | .split-line:after { 101 | content: ''; 102 | position: absolute; 103 | width: 30rpx; 104 | height: 15rpx; 105 | background: #fff; 106 | left: -15rpx; 107 | z-index: 1; 108 | } 109 | 110 | .split-line:before { 111 | border-radius: 0 0 15rpx 15rpx; 112 | top: 0; 113 | } 114 | 115 | .split-line:after { 116 | border-radius: 15rpx 15rpx 0 0; 117 | bottom: 0; 118 | } 119 | 120 | .border-line { 121 | position: absolute; 122 | height: 210rpx; 123 | flex: 0 0 0; 124 | right:0; 125 | top:0; 126 | } 127 | 128 | .border-line:before, 129 | .border-line:after { 130 | content: ''; 131 | position: absolute; 132 | width: 16rpx; 133 | height: 10rpx; 134 | background: #fff; 135 | left: -9rpx; 136 | z-index: 1; 137 | } 138 | 139 | .border-line .border-circle { 140 | position:absolute; 141 | width:15rpx; 142 | height:30rpx; 143 | background:#fff; 144 | top:50%; 145 | transform:translateY(-50%); 146 | left:-14rpx; 147 | z-index:1; 148 | border-radius:15rpx 0rpx 0rpx 15rpx; 149 | } 150 | 151 | .border-line:before { 152 | border-radius: 0 0 10rpx 10rpx; 153 | top: 0; 154 | } 155 | 156 | .border-line:after { 157 | border-radius: 10rpx 10rpx 0 0; 158 | bottom: 0; 159 | } 160 | 161 | .tip .checkbox { 162 | width: 42rpx; 163 | height: 42rpx; 164 | position: absolute; 165 | border-radius: 50%; 166 | background: #fff; 167 | top: 18rpx; 168 | right: 18rpx; 169 | } 170 | .tip .checkbox .checkbox_img{ 171 | width: 42rpx; 172 | height: 42rpx; 173 | } 174 | .tip .money { 175 | position: absolute; 176 | top: 50%; 177 | left: 50%; 178 | transform: translate(-50%,-50%); 179 | font-size: 50rpx; 180 | padding-right:18rpx; 181 | } 182 | .tip .money .money_symbol{ 183 | font-size: 35rpx; 184 | } -------------------------------------------------------------------------------- /components/GetCard/GetCard.js: -------------------------------------------------------------------------------- 1 | // components/GetCard/GetCard.js 2 | Component({ 3 | /** 4 | * 组件的属性列表 5 | */ 6 | properties: { 7 | info: { // 信息数据 8 | type: Object, 9 | value: { 10 | 'logoWx': '../../resource/image/card2.png', 11 | 'rightsDiscribe': '描述', 12 | 'brandName': '默认卡' 13 | } 14 | }, 15 | ishidden: { 16 | type: Boolean, 17 | value: false 18 | }, 19 | }, 20 | 21 | /** 22 | * 组件的初始数据 23 | */ 24 | data: { 25 | 26 | }, 27 | 28 | /** 29 | * 组件的方法列表 30 | */ 31 | methods: { 32 | _getCardEvent() { 33 | var obj = this.properties.info; 34 | var myEventDetail = obj; // detail对象,提供给事件监听函数 35 | var myEventOption = {}; // 触发事件的选项 36 | this.triggerEvent('getCardEvent', myEventDetail, myEventOption); 37 | } 38 | } 39 | }) 40 | -------------------------------------------------------------------------------- /components/GetCard/GetCard.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /components/GetCard/GetCard.wxml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /components/GetCard/GetCard.wxss: -------------------------------------------------------------------------------- 1 | /* components/GetCard/GetCard.wxss */ 2 | .getcard_wrap{ 3 | width: 330rpx; 4 | } 5 | .icon{ 6 | position: relative; 7 | width: 330rpx; 8 | height: 210rpx; 9 | border-radius: 12rpx; 10 | overflow: hidden; 11 | } 12 | .icon .icon_wrap{ 13 | font-size: 0; 14 | } 15 | .icon .icon_wrap .icon_img{ 16 | width: 330rpx; 17 | height: 210rpx; 18 | } 19 | .icon .card_text{ 20 | position: absolute; 21 | width: 100%; 22 | height: 64rpx; 23 | bottom: 0; 24 | background: rgba(0,0,0,0.50); 25 | overflow: hidden; 26 | text-overflow:ellipsis; 27 | white-space: nowrap; 28 | color: #fff; 29 | } 30 | .icon .card_text .text{ 31 | font-size: 28rpx; 32 | line-height: 28rpx; 33 | padding-left: 10rpx; 34 | } 35 | 36 | .card_desc{ 37 | display: flex; 38 | margin-top: 15rpx; 39 | } 40 | .card_desc .title{ 41 | flex: 1; 42 | font-size: 28rpx; 43 | line-height: 28rpx; 44 | overflow: hidden; 45 | text-overflow:ellipsis; 46 | white-space: nowrap; 47 | } 48 | .card_desc .get_btn{ 49 | display: block; 50 | background: #007AFF; 51 | border-radius: 100px; 52 | font-size: 18rpx; 53 | line-height: 18rpx; 54 | padding: 6rpx 18rpx; 55 | color: #fff; 56 | } -------------------------------------------------------------------------------- /components/List/List.js: -------------------------------------------------------------------------------- 1 | // components/List/list.js 2 | Component({ 3 | /** 4 | * 组件的属性列表 5 | */ 6 | properties: { 7 | 8 | }, 9 | 10 | /** 11 | * 组件的初始数据 12 | */ 13 | data: { 14 | 15 | }, 16 | 17 | /** 18 | * 组件的方法列表 19 | */ 20 | methods: { 21 | 22 | } 23 | }) 24 | -------------------------------------------------------------------------------- /components/List/List.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /components/List/List.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /components/List/List.wxss: -------------------------------------------------------------------------------- 1 | /* components/List/list.wxss */ -------------------------------------------------------------------------------- /components/List/ListItem.js: -------------------------------------------------------------------------------- 1 | // components/List/ListItem.js 2 | Component({ 3 | options: { 4 | multipleSlots: true // 在组件定义时的选项中启用多slot支持 5 | }, 6 | /** 7 | * 组件的属性列表 8 | */ 9 | properties: { 10 | arrow:{ 11 | type:String, // 默认不显箭头 12 | value:'empty' 13 | }, 14 | bottomline:{ // 默认显示下边框 15 | type:Boolean, 16 | value:true 17 | }, 18 | hidden:{ // 默认不隐藏 19 | type:Boolean, 20 | value:false 21 | } 22 | }, 23 | 24 | /** 25 | * 组件的初始数据 26 | */ 27 | data: { 28 | 29 | }, 30 | 31 | /** 32 | * 组件的方法列表 33 | */ 34 | methods: { 35 | 36 | } 37 | }) 38 | -------------------------------------------------------------------------------- /components/List/ListItem.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /components/List/ListItem.wxml: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /components/List/ListItem.wxss: -------------------------------------------------------------------------------- 1 | /* components/List/ListItem.wxss */ 2 | .bottom_line{border-bottom: 2rpx solid #E4E4E4;} 3 | .swift_list_item{background:#ffffff;font-size:28rpx;padding:19rpx 28rpx;display:-webkit-box;} 4 | .swift_list_item_left{-webkit-box-flex: 1;display:block;} 5 | .swift_list_item_right{display:block;color:#4F5EFF;} 6 | .swift_list_arrow{display:block;width:12rpx;margin-left:10rpx;} 7 | .swift_list_arrow .arrow_right{width:12rpx;height:20rpx;} -------------------------------------------------------------------------------- /pages/activity/activity.js: -------------------------------------------------------------------------------- 1 | // pages/activity.js 2 | var util = require('../../utils/util.js'); 3 | Page({ 4 | 5 | /** 6 | * 页面的初始数据 7 | */ 8 | data: { 9 | activity:{} 10 | }, 11 | 12 | /** 13 | * 生命周期函数--监听页面加载 14 | */ 15 | onLoad: function (options) { 16 | this.initPage(); 17 | }, 18 | 19 | initPage:function(){ 20 | var topup_activity = wx.getStorageSync("topup_activity"); 21 | topup_activity.beginDate = util.formatYMD(new Date(topup_activity.beginDate)); 22 | topup_activity.endDate = util.formatYMD(new Date(topup_activity.endDate)); 23 | var rule = topup_activity.rule && JSON.parse(topup_activity.rule) || []; 24 | rule.forEach(function (item) { 25 | item.conditionAmount && (item.conditionAmount = parseFloat(item.conditionAmount / 100).toFixed(2)); 26 | item.discountVar && (item.discountVar = parseFloat(item.discountVar / 100).toFixed(2)); 27 | item.discountMaxAmount && (item.discountMaxAmount = parseFloat(item.discountMaxAmount / 100).toFixed(2)); 28 | }); 29 | topup_activity.rule = rule; 30 | 31 | console.log(2,topup_activity) 32 | 33 | this.setData({ 34 | activity:topup_activity 35 | }); 36 | }, 37 | 38 | /** 39 | * 生命周期函数--监听页面初次渲染完成 40 | */ 41 | onReady: function () { 42 | 43 | }, 44 | 45 | /** 46 | * 生命周期函数--监听页面显示 47 | */ 48 | onShow: function () { 49 | 50 | }, 51 | 52 | /** 53 | * 生命周期函数--监听页面隐藏 54 | */ 55 | onHide: function () { 56 | 57 | }, 58 | 59 | /** 60 | * 生命周期函数--监听页面卸载 61 | */ 62 | onUnload: function () { 63 | 64 | }, 65 | 66 | /** 67 | * 页面相关事件处理函数--监听用户下拉动作 68 | */ 69 | onPullDownRefresh: function () { 70 | 71 | }, 72 | 73 | /** 74 | * 页面上拉触底事件的处理函数 75 | */ 76 | onReachBottom: function () { 77 | 78 | }, 79 | 80 | /** 81 | * 用户点击右上角分享 82 | */ 83 | onShareAppMessage: function () { 84 | 85 | } 86 | }) -------------------------------------------------------------------------------- /pages/activity/activity.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/activity/activity.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 充值 16 | 满{{item.conditionAmount}}元,赠送{{item.discountVar}}元 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 充值 32 | 满{{item.conditionAmount}}元,减少{{item.discountVar}}元 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 充值 48 | 满{{item.conditionAmount}}元{{item.discountVar}}折 49 | 50 | 单笔订单最高折扣 51 | {{item.discountMaxAmount}}元 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 活动规则:{{activity.ruleStr}} 62 | 63 | 64 | 活动时间:{{activity.beginDate}}-{{activity.endDate}} 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /pages/activity/activity.wxss: -------------------------------------------------------------------------------- 1 | /* pages/activity.wxss */ 2 | page{ 3 | height: 100%; 4 | } 5 | .activity_wrap{ 6 | display: flex; 7 | flex-direction: column; 8 | min-height: 100%; 9 | background: #fff; 10 | } 11 | .content{ 12 | flex: 1; 13 | padding: 76rpx 70rpx; 14 | } 15 | .content .content_wrap{ 16 | position: relative; 17 | } 18 | .content_bg .content_bg_img{ 19 | width: 610rpx; 20 | height: 948rpx; 21 | } 22 | .activity_content{ 23 | position: absolute; 24 | top:268rpx; 25 | width: 100%; 26 | } 27 | .activity_item{ 28 | display: -webkit-box; 29 | } 30 | .activity_item .item_icon{ 31 | width:162rpx; 32 | display: flex; 33 | justify-content: center; 34 | align-items: center; 35 | } 36 | .activity_item .item_icon .item_icon_img{ 37 | width: 36rpx; 38 | height: 36rpx; 39 | } 40 | .activity_item .text{ 41 | -webkit-box-flex:1; 42 | display: block; 43 | font-size: 28rpx; 44 | line-height: 40rpx; 45 | } 46 | .activity_item .text .blue{ 47 | color: #5261FF; 48 | } 49 | 50 | .split_line_wrap{ 51 | display: flex; 52 | align-content: center; 53 | justify-content:center; 54 | } 55 | .split_line_wrap .split_line{ 56 | border-bottom: 2rpx solid #C0C5FF; 57 | padding-bottom: 35rpx; 58 | margin-bottom: 35rpx; 59 | width: 60%; 60 | 61 | } 62 | .footer{ 63 | font-size: 28rpx; 64 | color: #212121; 65 | padding: 88rpx 36rpx 0 36rpx; 66 | } 67 | .footer_time{ 68 | font-size: 24rpx; 69 | color: #212121; 70 | padding: 18rpx 36rpx 0 36rpx; 71 | } -------------------------------------------------------------------------------- /pages/card/cardDetail.js: -------------------------------------------------------------------------------- 1 | // pages/card/cardDetail.js 2 | var app = getApp(); 3 | Page({ 4 | 5 | /** 6 | * 页面的初始数据 7 | */ 8 | data: { 9 | newUser: true, 10 | card : null 11 | }, 12 | obj: { 13 | loading: false, 14 | needLoad : true 15 | }, 16 | 17 | /** 18 | * 生命周期函数--监听页面加载 19 | */ 20 | onLoad: function (options) { 21 | wx.setStorageSync('page_carddetail', true); 22 | this.obj.spid = decodeURIComponent(options.spid); 23 | var redirect = decodeURIComponent(options.redirect || ''); 24 | var cardId = decodeURIComponent(options.cardId || ''); 25 | if(redirect && redirect !== '/pages/card/cardDetail' && cardId){ 26 | var that = this; 27 | this.obj.needLoad = false; 28 | wx.navigateTo({ 29 | url: redirect + '?spid=' + that.obj.spid + '&cardId=' + cardId, 30 | complete:function () { 31 | that.obj.needLoad = true; 32 | } 33 | }); 34 | } 35 | }, 36 | 37 | /** 38 | * 生命周期函数--监听页面初次渲染完成 39 | */ 40 | onReady: function () { 41 | 42 | }, 43 | 44 | /** 45 | * 生命周期函数--监听页面显示 46 | */ 47 | onShow: function () { 48 | if(this.obj.needLoad){ 49 | var needloading = wx.getStorageSync('page_carddetail') || false; 50 | if (needloading) { 51 | wx.removeStorageSync('page_carddetail'); 52 | this.loadData(); 53 | } 54 | } 55 | }, 56 | 57 | /** 58 | * 生命周期函数--监听页面隐藏 59 | */ 60 | onHide: function () { 61 | 62 | }, 63 | 64 | /** 65 | * 生命周期函数--监听页面卸载 66 | */ 67 | onUnload: function () { 68 | 69 | }, 70 | 71 | /** 72 | * 页面相关事件处理函数--监听用户下拉动作 73 | */ 74 | onPullDownRefresh: function () { 75 | this.loadData(); 76 | }, 77 | 78 | /** 79 | * 页面上拉触底事件的处理函数 80 | */ 81 | onReachBottom: function () { 82 | 83 | }, 84 | 85 | /** 86 | * 用户点击右上角分享 87 | */ 88 | onShareAppMessage: function () { 89 | 90 | }, 91 | 92 | loadData: function () { 93 | var that = this; 94 | if(!this.obj.spid) { 95 | wx.showModal({ 96 | title: '出错了', 97 | content: '无法获取领卡商户信息', 98 | showCancel: false 99 | }); 100 | return; 101 | } 102 | wx.showNavigationBarLoading(); 103 | that.obj.loading = true; 104 | wx.showLoading({ 105 | title: '加载中', 106 | mask: true, 107 | success: function () { 108 | app.request({ 109 | url: '/user/card/query', 110 | data: { 111 | spid: that.obj.spid 112 | }, 113 | success: function (res) { 114 | if (res.data.data) { 115 | if(!res.data.data.newUser && res.data.data.userCard){ 116 | res.data.data.userCard.balance = res.data.data.userCard.balance.toFixed(2); 117 | } 118 | that.setData({ 119 | newUser: res.data.data.newUser, 120 | card : res.data.data.card, 121 | userCard : res.data.data.userCard 122 | }); 123 | } 124 | }, 125 | complete: function (res) { 126 | wx.hideLoading(); 127 | wx.hideNavigationBarLoading(); 128 | wx.stopPullDownRefresh(); 129 | that.obj.loading = false; 130 | } 131 | }); 132 | } 133 | }); 134 | }, 135 | 136 | handleCardClick:function (e) { 137 | var that = this; 138 | if(!this.obj.spid) { 139 | wx.showModal({ 140 | title: '出错了', 141 | content: '无法获取领卡商户信息', 142 | showCancel: false 143 | }); 144 | return; 145 | } 146 | 147 | var cardId = e.currentTarget.dataset.id; 148 | if(this.data.userCard){ 149 | that.obj.loading = true; 150 | wx.showLoading({ 151 | title: '加载中', 152 | mask: true, 153 | success: function () { 154 | app.request({ 155 | url: '/user/card/open', 156 | data: { 157 | cardId:cardId, 158 | spid: that.obj.spid 159 | }, 160 | success: function (res) { 161 | if (res.data && res.data.data && res.data.data.wxPacket) { 162 | wx.openCard({ 163 | cardList: [{ 164 | cardId: res.data.data.wxCardId, 165 | code: res.data.data.code 166 | }], 167 | success: function (res) { 168 | that.loadData(true); 169 | } 170 | }); 171 | } else { 172 | var card = (res.data && res.data.data) || {}; 173 | wx.addCard({ 174 | cardList: [{ 175 | cardId: card.wxCardId, 176 | cardExt: '{"code": "' + card.code + '", "openid":"", "timestamp": "' + card.timestamp + '", "nonce_str":"' + card.nonceStr + '", "signature":"' + card.signature + '"}' 177 | }], 178 | success: function (res) { 179 | that.loadData(); 180 | } 181 | }); 182 | } 183 | }, 184 | complete: function (res) { 185 | wx.hideLoading(); 186 | that.obj.loading = false; 187 | } 188 | }); 189 | } 190 | }); 191 | } 192 | }, 193 | 194 | handleRecieveCardClick:function (e) { 195 | var that = this; 196 | if(!this.obj.spid) { 197 | wx.showModal({ 198 | title: '出错了', 199 | content: '无法获取领卡商户信息', 200 | showCancel: false 201 | }); 202 | return; 203 | } 204 | 205 | if(this.data.card){ 206 | that.obj.loading = true; 207 | wx.showLoading({ 208 | title: '加载中', 209 | mask: true, 210 | success: function () { 211 | app.request({ 212 | url: '/mch/card/recieve', 213 | data: { 214 | spid: that.obj.spid 215 | }, 216 | success: function (res) { 217 | if (res.data && res.data.data && res.data.data.wxPacket) { 218 | wx.openCard({ 219 | cardList: [{ 220 | cardId: res.data.data.wxCardId, 221 | code: res.data.data.code 222 | }], 223 | success: function () { 224 | that.loadData(true); 225 | } 226 | }); 227 | } else { 228 | var card = (res.data && res.data.data) || {}; 229 | wx.addCard({ 230 | cardList: [{ 231 | cardId: card.wxCardId, 232 | cardExt: '{"code": "' + card.code + '", "openid":"", "timestamp": "' + card.timestamp + '", "nonce_str":"' + card.nonceStr + '", "signature":"' + card.signature + '"}' 233 | }], 234 | success: function () { 235 | that.loadData(); 236 | }, 237 | fail:function (addres) { 238 | if(addres.errMsg === 'addCard:fail cancel'){ 239 | that.loadData(); 240 | } 241 | } 242 | }); 243 | } 244 | }, 245 | complete: function (res) { 246 | wx.hideLoading(); 247 | that.obj.loading = false; 248 | } 249 | }); 250 | } 251 | }); 252 | } 253 | } 254 | }); -------------------------------------------------------------------------------- /pages/card/cardDetail.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": true 3 | } -------------------------------------------------------------------------------- /pages/card/cardDetail.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{card.brandName}} 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 会员福利 18 | 19 | 20 | {{item.content}} 21 | 22 | 23 | 使用须知 24 | 25 | 26 | {{card.describe}} 27 | 28 | 29 | 30 | 31 | 帮助中心 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | {{userCard.brandName}} 44 | 45 | 查看会员权益> 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | {{userCard.bonus}} 57 | 积分 58 | 59 | 60 | 61 | {{userCard.balance}}元 62 | 余额 63 | 64 | 65 | 66 | {{userCard.levelName}} 67 | 等级V{{userCard.level || 0}} 68 | 69 | 70 | 71 | 72 | 73 | 74 | 充值 75 | 76 | 77 | 78 | 交易记录 79 | 80 | 81 | 82 | 优惠券 83 | 84 | 85 | 86 | 积分记录 87 | 88 | 89 | 90 | 91 | 帮助中心 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /pages/card/cardDetail.wxss: -------------------------------------------------------------------------------- 1 | /* pages/card/cardDetail.wxss */ 2 | .blue_bg{padding-top: 100rpx; background: #3C4FA0;} 3 | .card_wrap{margin: 0 24rpx; height: 464rpx; position: relative;} 4 | .card_wrap .card{position: absolute; left: 0; top: 0; width: 100%; height: 100%;} 5 | .customer_info{height: 300rpx; margin: 0 20rpx; border-bottom: 1px solid rgba(151, 151, 151, 0.14); position: relative; overflow: hidden; text-align: center;} 6 | .customer_info .logo{width: 100rpx; height: 100rpx; margin: 40rpx auto 20rpx;} 7 | .customer_info .logo image{width: 100%; height: 100%;border-radius:100rpx;} 8 | .customer_info text{font-size: 34rpx; line-height: 48rpx; color: #333;} 9 | .customer_info .nav_wrap{margin-top: 10rpx;} 10 | .customer_info .nav_wrap navigator{display: inline-block; font-size: 28rpx; line-height: 40rpx; color: #999;} 11 | .customer_info .nav_wrap text{font-family: '宋体'; vertical-align: middle; color: #999; margin-left: 10rpx;} 12 | .index_btn_wrap{margin-top: 32rpx;} 13 | .w250{width: 250rpx;} 14 | .member_info{height: 158rpx; background: #4D62BE; box-shadow: 0 2px 4px rgba(0, 0, 0, .5); margin-top: -20rpx; position: relative; display: -webkit-box; -webkit-box-align: center;} 15 | .member_info .item{width: 1rpx; -webkit-box-flex: 1; text-align: center; position: relative;} 16 | .member_info .split{width: 1rpx; height: 30rpx; background: rgba(255, 255, 255, .4);} 17 | .member_info .item .item_top{font-size: 32rpx; line-height: 45rpx; color: #fff;} 18 | .member_info .item .item_btm{font-size: 28rpx; line-height: 40rpx; color: rgba(255, 255, 255, .3);} 19 | .member_info .item .item_btm text{margin-left: 10rpx;} 20 | .member_service{display: -webkit-box; margin-top: 60rpx;} 21 | .member_service .item{width: 1rpx; -webkit-box-flex: 1; text-align: center;} 22 | .member_service .item image{width: 54rpx; height: 54rpx;} 23 | .member_service view{font-size: 28rpx; line-height: 40rpx; color: #333; margin-top: 30rpx;} 24 | 25 | .help_center{position: absolute; left: 0; right: 0; bottom: 32rpx; font-size: 28rpx; line-height: 40rpx; color: #999; text-align: center;} 26 | .help_center navigator{display: inline-block;} 27 | 28 | /* pages/card/newMember.wxss */ 29 | .blue_bg_new{height: 220rpx;background: #3C4FA0;} 30 | .card_wrap_new{margin: -140rpx 24rpx 0; height: 464rpx; position: relative;} 31 | .card_wrap_new .card{position: absolute; left: 0; top: 0; width: 100%; height: 100%;} 32 | .customer_info_new{ 33 | height: 300rpx; margin: 0 20rpx; border-bottom: 1px solid rgba(151, 151, 151, 0.14); 34 | position: relative; overflow: hidden; text-align: center; 35 | } 36 | .customer_info_new .logo{width: 166rpx; height: 166rpx; margin: 40rpx auto 22rpx;} 37 | .customer_info_new .logo image{width: 100%; height: 100%;border-radius: 166rpx;} 38 | .customer_info_new text{font-size: 34rpx; line-height: 48rpx; color: #333;} 39 | .index_btn_wrap{margin-top: 32rpx;} 40 | .w250{width: 250rpx;} 41 | .card_intro{ 42 | margin-top: 70rpx; text-align: center; 43 | position:absolute;left:0;right:0;bottom:100rpx;top:500rpx;overflow: auto; 44 | } 45 | .card_intro .intro_title{display: -webkit-box; -webkit-box-align: center; -webkit-box-pack: center;} 46 | .card_intro .intro_title text{margin: 0 60rpx; font-size: 28rpx; line-height: 40rpx;} 47 | .card_intro .intro_title .line{width: 100rpx; height: 2rpx; background: #E4E4E4;} 48 | .card_intro .intro_con{margin-top: 12rpx;padding:0 160rpx;} 49 | .card_intro .intro_con .row{font-size: 28rpx; line-height: 40rpx; color: #999;} 50 | .mt56{margin-top: 56rpx;} 51 | .help_center{position: absolute; left: 0; right: 0; bottom: 32rpx; font-size: 28rpx; line-height: 40rpx; color: #999; text-align: center;} 52 | .help_center navigator{display: inline-block;} -------------------------------------------------------------------------------- /pages/card/cardIndex.js: -------------------------------------------------------------------------------- 1 | // pages/card/cardIndex.js 2 | var app = getApp(); 3 | var util = require('../../utils/util.js'); 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | cardList: [], 11 | 12 | imgUrls: [ 13 | '../../resource/image/member_card_banner.png' 14 | // 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg', 15 | // 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg', 16 | // 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg' 17 | ], 18 | indicatorDots: false, 19 | autoplay: true, 20 | interval: 5000, 21 | duration: 1000 22 | }, 23 | obj: { 24 | currentPage: 1, 25 | hasNext: true, 26 | loading: false 27 | }, 28 | 29 | /** 30 | * 生命周期函数--监听页面加载 31 | */ 32 | onLoad: function (options) { 33 | wx.setStorageSync('page_cardindex', true); 34 | wx.removeStorageSync('page_cardindexnewu'); 35 | }, 36 | 37 | /** 38 | * 生命周期函数--监听页面初次渲染完成 39 | */ 40 | onReady: function () { 41 | 42 | }, 43 | 44 | /** 45 | * 生命周期函数--监听页面显示 46 | */ 47 | onShow: function () { 48 | var that = this; 49 | var needloading = wx.getStorageSync('page_cardindex') || false; 50 | if (needloading) { 51 | that.obj = { 52 | currentPage: 1, 53 | hasNext: true, 54 | loading: false 55 | }; 56 | that.loadData(true); 57 | } 58 | }, 59 | 60 | /** 61 | * 生命周期函数--监听页面隐藏 62 | */ 63 | onHide: function () { 64 | 65 | }, 66 | 67 | /** 68 | * 生命周期函数--监听页面卸载 69 | */ 70 | onUnload: function () { 71 | 72 | }, 73 | 74 | /** 75 | * 页面相关事件处理函数--监听用户下拉动作 76 | */ 77 | onPullDownRefresh: function () { 78 | var that = this; 79 | that.obj.currentPage = 1; 80 | that.obj.hasNext = true; 81 | that.loadData(true); 82 | }, 83 | 84 | /** 85 | * 页面上拉触底事件的处理函数 86 | */ 87 | onReachBottom: function () { 88 | 89 | }, 90 | 91 | /** 92 | * 用户点击右上角分享 93 | */ 94 | onShareAppMessage: function () { 95 | 96 | }, 97 | 98 | loadData: function (flag) { 99 | var that = this; 100 | if (that.obj.hasNext && !that.obj.loading) { 101 | if (flag) { 102 | wx.showNavigationBarLoading(); 103 | } 104 | that.obj.loading = true; 105 | // var currentPage = that.obj.currentPage; 106 | var currentPage = 1; 107 | wx.showLoading({ 108 | title: '加载中', 109 | mask: true, 110 | success: function () { 111 | app.request({ 112 | url: '/user/card/list', 113 | data: { 114 | currentPage: currentPage, 115 | pageSize: 10 116 | }, 117 | success: function (res) { 118 | try { 119 | wx.setStorageSync('page_cardindex', false); 120 | } catch (e) { 121 | } 122 | var data = res.data.data; 123 | if (data && data.length > 0) { 124 | var data = res.data.data || []; 125 | data.forEach(function (item) { 126 | item.expEndDate = util.formatYMD(new Date(item.expEndDate)); 127 | item.balance = util.formatFixed(item.balance / 100); 128 | }); 129 | that.setData({ 130 | cardList: data 131 | }); 132 | } else if (currentPage === 1) { 133 | wx.navigateTo({ 134 | url: '/pages/card/cardIndexNewUsr' 135 | }); 136 | } 137 | }, 138 | complete: function (res) { 139 | wx.hideLoading(); 140 | if (flag) { 141 | wx.hideNavigationBarLoading(); 142 | } 143 | wx.stopPullDownRefresh(); 144 | that.obj.loading = false; 145 | } 146 | }); 147 | } 148 | }); 149 | 150 | } 151 | }, 152 | 153 | handleCardClick: function (e) { 154 | var cardId = e.currentTarget.dataset.id; 155 | var spid = e.currentTarget.dataset.spid; 156 | wx.navigateTo({ 157 | url: '/pages/card/cardDetail?spid=' + spid + '&cardId=' + cardId 158 | }); 159 | // var that = this; 160 | // wx.showLoading({ 161 | // title: '加载中', 162 | // mask: true, 163 | // success: function () { 164 | // app.request({ 165 | // url: '/user/card/open', 166 | // data: { 167 | // cardId: cardId, 168 | // spid: spid 169 | // }, 170 | // success: function (res) { 171 | // if (res.data && res.data.data && res.data.data.wxPacket) { 172 | // wx.openCard({ 173 | // cardList: [{ 174 | // cardId: res.data.data.wxCardId, 175 | // code: res.data.data.code 176 | // }], 177 | // success: function (res) { 178 | // // that.loadData(true); 179 | // } 180 | // }); 181 | // } else { 182 | // var card = (res.data && res.data.data) || {}; 183 | // wx.addCard({ 184 | // cardList: [{ 185 | // cardId: card.wxCardId, 186 | // cardExt: '{"code": "' + card.code + '", "openid":"", "timestamp": "' + card.timestamp + '", "nonce_str":"' + card.nonceStr + '", "signature":"' + card.signature + '"}' 187 | // }], 188 | // success: function (res) { 189 | // // that.loadData(true); 190 | // } 191 | // }); 192 | // } 193 | // }, 194 | // complete: function (res) { 195 | // wx.hideLoading(); 196 | // } 197 | // }); 198 | // } 199 | // }); 200 | } 201 | }); -------------------------------------------------------------------------------- /pages/card/cardIndex.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": true 3 | } -------------------------------------------------------------------------------- /pages/card/cardIndex.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | {{item.brandName}} 18 | 有效期至:{{item.expEndDate}} 19 | 余额: 20 | ¥{{item.balance}} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 帮助中心 28 | | 29 | 更多会员卡 30 | 31 | -------------------------------------------------------------------------------- /pages/card/cardIndex.wxss: -------------------------------------------------------------------------------- 1 | /* pages/card/cardIndex.wxss */ 2 | page{ 3 | height: 100%; 4 | } 5 | .content_wrap{ 6 | min-height: 100%; 7 | display: flex; 8 | flex-direction: column; 9 | } 10 | .slide-image{ 11 | width: 100%; 12 | } 13 | 14 | .wrapper{ 15 | flex: 1; 16 | background:#fff; 17 | } 18 | .wrapper .card_wrap{padding: 70rpx 48rpx;} 19 | 20 | .card_line{ 21 | display: flex; 22 | padding: 30rpx 0; 23 | border-bottom: 2rpx solid #E4E4E4; 24 | } 25 | .card_line:last-child{ 26 | border-bottom: none; 27 | } 28 | .card_line .card_left{ 29 | flex:0 0 287rpx; 30 | width: 259rpx; 31 | height: 150rpx; 32 | } 33 | .card_line .card_left .icon_img{ 34 | width: 259rpx; 35 | height: 150rpx; 36 | border-radius: 12rpx; 37 | } 38 | 39 | .card_line .card_right{ 40 | flex:1; 41 | } 42 | .card_line .card_right .title{ 43 | font-size: 28rpx; 44 | } 45 | .card_line .card_right .time{ 46 | font-size: 24rpx; 47 | color: #999999; 48 | margin-top: 5rpx; 49 | } 50 | .card_line .card_right .money{ 51 | margin-top: 30rpx; 52 | display: inline-block; 53 | font-size: 24rpx; 54 | color: #999999; 55 | } 56 | .card_line .card_right .money .ant{ 57 | display: inline-block; 58 | font-size: 38rpx; 59 | color: #EA5252; 60 | } 61 | 62 | .footer{background: #fff;height: 64rpx; line-height: 40rpx; text-align: center;} 63 | .footer .split{display: inline-block; padding: 0 18rpx; color: #999;} 64 | .footer navigator{display: inline-block; font-size: 28rpx; color: #999;} -------------------------------------------------------------------------------- /pages/card/cardIndexNewUsr.js: -------------------------------------------------------------------------------- 1 | // pages/card/cardIndexNewUsr.js 2 | var app = getApp(); 3 | Page({ 4 | 5 | /** 6 | * 页面的初始数据 7 | */ 8 | data: { 9 | cardInfoList: [], // 优惠券信息列表 10 | 11 | imgUrls: [ 12 | '../../resource/image/member_card_banner.png' 13 | // 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg' 14 | // 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg', 15 | // 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg' 16 | ], 17 | indicatorDots: false, 18 | autoplay: true, 19 | interval: 5000, 20 | duration: 1000 21 | }, 22 | obj: { 23 | currentPage: 1, 24 | hasNext: true, 25 | loading: false 26 | }, 27 | 28 | /** 29 | * 生命周期函数--监听页面加载 30 | */ 31 | onLoad: function (options) { 32 | wx.setStorageSync('page_cardindex', true); 33 | wx.setStorageSync('page_cardindexnewu', true); 34 | }, 35 | 36 | /** 37 | * 生命周期函数--监听页面初次渲染完成 38 | */ 39 | onReady: function () { 40 | 41 | }, 42 | 43 | /** 44 | * 生命周期函数--监听页面显示 45 | */ 46 | onShow: function () { 47 | var that = this; 48 | var needloading = wx.getStorageSync('page_cardindexnewu') || false; 49 | if (needloading) { 50 | that.obj = { 51 | currentPage: 1, 52 | hasNext: true, 53 | loading: false 54 | }; 55 | that.loadData(true); 56 | } 57 | }, 58 | 59 | /** 60 | * 生命周期函数--监听页面隐藏 61 | */ 62 | onHide: function () { 63 | 64 | }, 65 | 66 | /** 67 | * 生命周期函数--监听页面卸载 68 | */ 69 | onUnload: function () { 70 | wx.removeStorageSync('page_cardindexnewu'); 71 | }, 72 | 73 | /** 74 | * 页面相关事件处理函数--监听用户下拉动作 75 | */ 76 | onPullDownRefresh: function () { 77 | var that = this; 78 | that.obj.currentPage = 1; 79 | that.obj.hasNext = true; 80 | that.loadData(true); 81 | }, 82 | 83 | /** 84 | * 页面上拉触底事件的处理函数 85 | */ 86 | onReachBottom: function () { 87 | 88 | }, 89 | 90 | /** 91 | * 用户点击右上角分享 92 | */ 93 | onShareAppMessage: function () { 94 | 95 | }, 96 | 97 | // 领取卡 98 | getCardEvent:function(e){ 99 | var currentCard = e.detail; 100 | wx.showLoading({ 101 | title: '加载中', 102 | mask: true, 103 | success: function () { 104 | app.request({ 105 | url: '/mch/card/recieve', 106 | data: { 107 | spid: currentCard.spid 108 | }, 109 | success: function (res) { 110 | if (res.data && res.data.data && res.data.data.wxPacket) { 111 | wx.openCard({ 112 | cardList: [{ 113 | cardId: res.data.data.wxCardId, 114 | code: res.data.data.code 115 | }], 116 | success: function (res) { 117 | 118 | }, 119 | complete: function () { 120 | wx.navigateBack(); 121 | } 122 | }); 123 | } else { 124 | var card = (res.data && res.data.data) || {}; 125 | wx.addCard({ 126 | cardList: [{ 127 | cardId: card.wxCardId, 128 | cardExt: '{"code": "' + card.code + '", "openid":"", "timestamp": "' + card.timestamp + '", "nonce_str":"' + card.nonceStr + '", "signature":"' + card.signature + '"}' 129 | }], 130 | success: function (res) { 131 | 132 | }, 133 | complete: function () { 134 | wx.navigateBack(); 135 | } 136 | }); 137 | } 138 | }, 139 | complete: function (res) { 140 | wx.hideLoading(); 141 | } 142 | }); 143 | }, 144 | complete: function (res) { 145 | console.log(res) 146 | } 147 | }); 148 | }, 149 | 150 | loadData: function (flag) { 151 | var that = this; 152 | if (that.obj.hasNext && !that.obj.loading) { 153 | if (flag) { 154 | wx.showNavigationBarLoading(); 155 | } 156 | that.obj.loading = true; 157 | // var currentPage = that.obj.currentPage; 158 | var currentPage = 1; 159 | wx.showLoading({ 160 | title: '加载中', 161 | mask: true, 162 | success: function () { 163 | app.request({ 164 | url: '/mch/card/list', 165 | data: { 166 | currentPage: currentPage, 167 | pageSize: 10 168 | }, 169 | success: function (res) { 170 | try { 171 | wx.setStorageSync('page_cardindexnewu', false); 172 | } catch (e) { 173 | } 174 | var data = res.data.data || []; 175 | 176 | var allData = []; //用来装处理完的数组 177 | var currData = []; //子数组用来存分割完的数据 178 | for (var i = 0; i < data.length; i++) { 179 | currData.push(data[i]); 180 | if ((i != 0 && (i + 1) % 2 == 0) || i == data.length - 1) { 181 | allData.push(currData); 182 | currData = []; 183 | } 184 | }; 185 | 186 | console.log(allData); 187 | 188 | that.setData({ 189 | cardInfoList: allData 190 | }); 191 | }, 192 | complete: function (res) { 193 | wx.hideLoading(); 194 | if (flag) { 195 | wx.hideNavigationBarLoading(); 196 | } 197 | wx.stopPullDownRefresh(); 198 | that.obj.loading = false; 199 | } 200 | }); 201 | } 202 | }); 203 | } 204 | } 205 | }); 206 | -------------------------------------------------------------------------------- /pages/card/cardIndexNewUsr.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": true, 3 | "usingComponents": { 4 | "GetCard": "/components/GetCard/GetCard" 5 | } 6 | } -------------------------------------------------------------------------------- /pages/card/cardIndexNewUsr.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 帮助中心 25 | 26 | 27 | -------------------------------------------------------------------------------- /pages/card/cardIndexNewUsr.wxss: -------------------------------------------------------------------------------- 1 | /* pages/card/cardIndexNewUsr.wxss */ 2 | page{ 3 | height: 100%; 4 | } 5 | .content_wrap{ 6 | min-height: 100%; 7 | display: flex; 8 | flex-direction: column; 9 | } 10 | .slide-image{ 11 | width: 100%; 12 | } 13 | .wrapper{ 14 | flex: 1; 15 | background:#fff; 16 | } 17 | .wrapper .card_wrap{padding: 42rpx 30rpx;} 18 | 19 | .card_line{ 20 | display: flex; 21 | padding-bottom: 35rpx; 22 | } 23 | .card_line .card_left{ 24 | flex:1; 25 | padding-right: 15rpx; 26 | } 27 | .card_line .card_right{ 28 | flex:1; 29 | padding-left: 15rpx; 30 | } 31 | 32 | .footer{background: #fff;height: 64rpx; line-height: 40rpx; text-align: center;} 33 | .footer navigator{display: inline-block; font-size: 28rpx; color: #999;} -------------------------------------------------------------------------------- /pages/coupons/couponList.js: -------------------------------------------------------------------------------- 1 | // pages/coupons/couponList.js 2 | var util = require('../../utils/util.js'); 3 | var app = getApp(); 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | couponList: [], // 优惠券列表 11 | useNoList: [], // 不可用优惠券列表 12 | useType: false, // 默认不使用优惠券 13 | seleCouponState: false, // 默认优惠券没有被选中 14 | }, 15 | obj:{ 16 | 17 | }, 18 | 19 | /** 20 | * 生命周期函数--监听页面加载 21 | */ 22 | onLoad: function (options) { 23 | this.obj.useSceneType = decodeURIComponent(options.useSceneType); 24 | this.obj.mchId = options.mchId && decodeURIComponent(options.mchId) || ''; 25 | this.obj.cardId = decodeURIComponent(options.cardId); 26 | this.obj.spid = decodeURIComponent(options.spid); 27 | 28 | var useConditionStr = decodeURIComponent(options.useCondition) || '0'; 29 | this.obj.useCondition = parseInt(useConditionStr, 10); 30 | }, 31 | 32 | /** 33 | * 生命周期函数--监听页面初次渲染完成 34 | */ 35 | onReady: function () { 36 | 37 | }, 38 | 39 | /** 40 | * 生命周期函数--监听页面显示 41 | */ 42 | onShow: function () { 43 | this.loadData(); 44 | }, 45 | 46 | /** 47 | * 生命周期函数--监听页面隐藏 48 | */ 49 | onHide: function () { 50 | 51 | }, 52 | 53 | /** 54 | * 生命周期函数--监听页面卸载 55 | */ 56 | onUnload: function () { 57 | 58 | }, 59 | 60 | /** 61 | * 页面相关事件处理函数--监听用户下拉动作 62 | */ 63 | onPullDownRefresh: function () { 64 | 65 | }, 66 | 67 | /** 68 | * 页面上拉触底事件的处理函数 69 | */ 70 | onReachBottom: function () { 71 | 72 | }, 73 | 74 | /** 75 | * 用户点击右上角分享 76 | */ 77 | onShareAppMessage: function () { 78 | 79 | }, 80 | 81 | // 不使用优惠券 82 | handleNoCouponSelect: function () { 83 | this.setData({ 84 | useType: false, 85 | seleCouponState:false 86 | }); 87 | }, 88 | 89 | // 选择优惠券 90 | selectCouponEvent:function(e){ 91 | console.log(e.detail); 92 | 93 | this.obj.selectCoupon = e.detail; 94 | this.setData({ 95 | useType:true 96 | }); 97 | }, 98 | 99 | // 确定 100 | handleSelect:function () { 101 | var useType = this.data.useType; 102 | if (useType) { 103 | wx.setStorageSync('counpon_selecct', { 104 | // useCondition : this.obj.useCondition, 105 | selectCoupon:this.obj.selectCoupon, 106 | useType:useType 107 | }); 108 | } else { 109 | wx.removeStorageSync('counpon_selecct'); 110 | } 111 | 112 | wx.navigateBack(); 113 | }, 114 | 115 | loadData: function () { 116 | console.log("优惠券",this.obj); 117 | var that = this; 118 | if (!this.obj.useSceneType || !this.obj.spid || !this.obj.cardId || this.obj.useCondition <= 0) { 119 | wx.showModal({ 120 | title: '出错了', 121 | content: '无法获取优惠券列表', 122 | showCancel: false 123 | }); 124 | return; 125 | } 126 | that.obj.loading = true; 127 | wx.showLoading({ 128 | title: '加载中', 129 | mask: true, 130 | success: function () { 131 | app.request({ 132 | url: '/user/card/coupon/qryCanAndCantUseCoupon', 133 | data: { 134 | useSceneType:that.obj.useSceneType, 135 | useCondition: (that.obj.useCondition / 100).toFixed(2), 136 | mchId: that.obj.mchId, 137 | cardId: that.obj.cardId, 138 | spid: that.obj.spid, 139 | }, 140 | success: function (res) { 141 | var couponList = []; 142 | var useNoList = []; 143 | if (res.data.data) { 144 | var list = res.data.data.dataList || []; 145 | for (var i = 0;i < list.length; i++) { 146 | var one = list[i]; 147 | one.startDate = util.formatYMD(new Date(one.effectiveDate)); 148 | one.endDate = util.formatYMD(new Date(one.expiryDate)); 149 | 150 | if (one.type == 1) { 151 | one.typeName = '代金券'; 152 | one.rightMoney = one.voucherPar; 153 | one.rightMoneyUnit = '元'; 154 | one.couponColor = 'red'; 155 | } if (one.type == 2) { 156 | one.typeName = '折扣券'; 157 | one.rightMoney = one.discountPar; 158 | one.rightMoneyUnit = '折'; 159 | one.couponColor = 'blue'; 160 | } else if (one.type == 3) { 161 | one.typeName = '满贈券'; 162 | one.rightMoney = one.presentPar 163 | one.rightMoneyUnit = '元'; 164 | one.couponColor = 'indigo'; 165 | } else if (one.type == 4) { 166 | one.typeName = '兑换券'; 167 | one.rightMoney = one.exchangeFaceVal 168 | one.rightMoneyUnit = '元'; 169 | one.couponColor = 'yellow'; 170 | } 171 | 172 | if (one.canUse === 1) { 173 | couponList.push(one); 174 | } else { 175 | useNoList.push(one); 176 | } 177 | } 178 | 179 | that.setData({ 180 | couponList, 181 | useNoList 182 | }); 183 | 184 | if(couponList.length == 0){ 185 | wx.showModal({ 186 | title: '提示', 187 | content: '当前没有可使用的优惠券', 188 | showCancel: false, 189 | success: function(res) { 190 | if (res.confirm) { 191 | wx.removeStorageSync('counpon_selecct'); 192 | wx.navigateBack(); 193 | } 194 | } 195 | }); 196 | } 197 | } 198 | }, 199 | complete: function () { 200 | wx.hideLoading(); 201 | wx.stopPullDownRefresh(); 202 | that.obj.loading = false; 203 | } 204 | }); 205 | } 206 | }); 207 | } 208 | }); -------------------------------------------------------------------------------- /pages/coupons/couponList.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": { 3 | "Coupon": "/components/Coupon/Coupon" 4 | } 5 | } -------------------------------------------------------------------------------- /pages/coupons/couponList.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 不使用优惠券 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 不可用的优惠券 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /pages/coupons/couponList.wxss: -------------------------------------------------------------------------------- 1 | /* pages/coupons/couponList.wxss */ 2 | .coupon_nonuse{ 3 | position: relative; 4 | height: 78rpx; 5 | background: #fff; 6 | text-align: center; 7 | line-height: 78rpx; 8 | font-size: 32rpx; 9 | color: #212121; 10 | letter-spacing: 2.29rpx; 11 | border-top: 2rpx solid rgba(151,151,151,0.2); 12 | border-bottom: 2rpx solid rgba(151,151,151,0.2); 13 | } 14 | .coupon_unselect_title{ 15 | display: inline-block; 16 | } 17 | .coupon_unselect{ 18 | position: absolute; 19 | width: 42rpx; 20 | height: 42rpx; 21 | border: 2rpx solid rgba(151,151,151,0.2); 22 | border-radius: 50%; 23 | background: #fff; 24 | top: 50%; 25 | transform: translateY(-50%); 26 | right: 42rpx; 27 | font-size: 0rpx; 28 | } 29 | .coupon_unselect .coupon_select_img{ 30 | width: 42rpx; 31 | height: 42rpx; 32 | } 33 | 34 | .coupon_list{ 35 | background: #fff; 36 | padding: 20rpx 30rpx; 37 | } 38 | .coupon_margin{ 39 | margin-bottom: 20rpx; 40 | } 41 | 42 | .use_no{ 43 | background: #fff; 44 | text-align: center; 45 | } 46 | .use_no .title{ 47 | color: #999; 48 | font-size: 28rpx; 49 | position: relative; 50 | padding: 0 20rpx; 51 | line-height: 40rpx; 52 | } 53 | .use_no .left{ 54 | display: inline-block; 55 | width:100rpx; 56 | height:2rpx; 57 | background:#E4E4E4; 58 | vertical-align: middle; 59 | } 60 | .use_no .right{ 61 | display: inline-block; 62 | width:100rpx; 63 | height:2rpx; 64 | background:#E4E4E4; 65 | vertical-align: middle; 66 | } 67 | 68 | .footer_btn{ 69 | padding: 20rpx 30rpx; 70 | } -------------------------------------------------------------------------------- /pages/coupons/couponListViewOnly.js: -------------------------------------------------------------------------------- 1 | // pages/coupons/couponListViewOnly.js 2 | var util = require('../../utils/util.js'); 3 | var app = getApp(); 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | couponList: [], // 优惠券列表 11 | useNoList: [], // 不可用优惠券列表 12 | 13 | couponsOpenOffState: true, // 不可用优惠券列表展示或显示状态 14 | }, 15 | obj:{ 16 | 17 | }, 18 | 19 | /** 20 | * 生命周期函数--监听页面加载 21 | */ 22 | onLoad: function (options) { 23 | this.obj.spid = decodeURIComponent(options.spid); 24 | }, 25 | 26 | /** 27 | * 生命周期函数--监听页面初次渲染完成 28 | */ 29 | onReady: function () { 30 | 31 | }, 32 | 33 | /** 34 | * 生命周期函数--监听页面显示 35 | */ 36 | onShow: function () { 37 | this.loadData(); 38 | }, 39 | 40 | /** 41 | * 生命周期函数--监听页面隐藏 42 | */ 43 | onHide: function () { 44 | 45 | }, 46 | 47 | /** 48 | * 生命周期函数--监听页面卸载 49 | */ 50 | onUnload: function () { 51 | 52 | }, 53 | 54 | /** 55 | * 页面相关事件处理函数--监听用户下拉动作 56 | */ 57 | onPullDownRefresh: function () { 58 | 59 | }, 60 | 61 | /** 62 | * 页面上拉触底事件的处理函数 63 | */ 64 | onReachBottom: function () { 65 | 66 | }, 67 | 68 | /** 69 | * 用户点击右上角分享 70 | */ 71 | onShareAppMessage: function () { 72 | 73 | }, 74 | 75 | // 选择优惠券 76 | selectCouponEvent:function(e){ 77 | this.obj.selectCoupon = e.detail; 78 | if (this.obj.selectCoupon.wxCardId && this.obj.selectCoupon.wxCode) { 79 | wx.openCard({ 80 | cardList: [{ 81 | cardId: this.obj.selectCoupon.wxCardId, 82 | code: this.obj.selectCoupon.wxCode 83 | }], 84 | success: function (res) { 85 | 86 | }, 87 | complete: function () { 88 | 89 | } 90 | }); 91 | } 92 | }, 93 | 94 | // 隐藏或显示无用优惠券 95 | couponsOpenOff:function(){ 96 | this.setData({ 97 | couponsOpenOffState:!this.data.couponsOpenOffState 98 | }); 99 | }, 100 | 101 | loadData: function () { 102 | var that = this; 103 | if (!this.obj.spid) { 104 | wx.showModal({ 105 | title: '出错了', 106 | content: '无法获取优惠券列表', 107 | showCancel: false 108 | }); 109 | return; 110 | } 111 | that.obj.loading = true; 112 | wx.showLoading({ 113 | title: '加载中', 114 | mask: true, 115 | success: function () { 116 | app.request({ 117 | url: '/user/card/coupon/qryCouponList', 118 | data: { 119 | spid: that.obj.spid, 120 | }, 121 | success: function (res) { 122 | var couponList = []; 123 | var useNoList = []; 124 | if (res.data.data) { 125 | var list = res.data.data.dataList || []; 126 | for (var i = 0;i < list.length; i++) { 127 | var one = list[i]; 128 | one.startDate = util.formatYMD(new Date(one.effectiveDate)); 129 | one.endDate = util.formatYMD(new Date(one.expiryDate)); 130 | 131 | if (one.type == 1) { 132 | one.typeName = '代金券'; 133 | one.rightMoney = one.voucherPar; 134 | one.rightMoneyUnit = '元'; 135 | one.couponColor = 'red'; 136 | } if (one.type == 2) { 137 | one.typeName = '折扣券'; 138 | one.rightMoney = one.discountPar; 139 | one.rightMoneyUnit = '折'; 140 | one.couponColor = 'blue'; 141 | } else if (one.type == 3) { 142 | one.typeName = '满贈券'; 143 | one.rightMoney = one.presentPar 144 | one.rightMoneyUnit = '元'; 145 | one.couponColor = 'indigo'; 146 | } else if (one.type == 4) { 147 | one.typeName = '兑换券'; 148 | one.rightMoney = one.exchangeFaceVal 149 | one.rightMoneyUnit = '元'; 150 | one.couponColor = 'yellow'; 151 | } 152 | 153 | if (one.state === 2) { 154 | couponList.push(one); 155 | } else { 156 | useNoList.push(one); 157 | } 158 | } 159 | 160 | that.setData({ 161 | couponList, 162 | useNoList 163 | }); 164 | 165 | if(couponList.length == 0){ 166 | wx.showModal({ 167 | title: '提示', 168 | content: '当前没有可使用的优惠券', 169 | showCancel: false, 170 | success: function(res) { 171 | if (res.confirm) { 172 | wx.navigateBack(); 173 | } 174 | } 175 | }); 176 | } 177 | } 178 | }, 179 | complete: function () { 180 | wx.hideLoading(); 181 | wx.stopPullDownRefresh(); 182 | that.obj.loading = false; 183 | } 184 | }); 185 | } 186 | }); 187 | } 188 | }); -------------------------------------------------------------------------------- /pages/coupons/couponListViewOnly.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": { 3 | "Coupon": "/components/Coupon/Coupon" 4 | } 5 | } -------------------------------------------------------------------------------- /pages/coupons/couponListViewOnly.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 不可用的优惠券 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /pages/coupons/couponListViewOnly.wxss: -------------------------------------------------------------------------------- 1 | /* pages/coupons/couponList.wxss */ 2 | .coupon_list{ 3 | background: #fff; 4 | padding: 20rpx 30rpx; 5 | } 6 | .coupon_margin{ 7 | margin-bottom: 20rpx; 8 | } 9 | 10 | .use_no{ 11 | background: #fff; 12 | text-align: center; 13 | } 14 | .use_no .title{ 15 | color: #999; 16 | font-size: 28rpx; 17 | position: relative; 18 | padding: 0 20rpx; 19 | line-height: 40rpx; 20 | } 21 | .use_no .left{ 22 | display: inline-block; 23 | width:100rpx; 24 | height:2rpx; 25 | background:#E4E4E4; 26 | vertical-align: middle; 27 | } 28 | .use_no .right{ 29 | display: inline-block; 30 | width:100rpx; 31 | height:2rpx; 32 | background:#E4E4E4; 33 | vertical-align: middle; 34 | } 35 | .use_no .on_off{ 36 | display: inline-block; 37 | position: absolute; 38 | right: 30rpx; 39 | } 40 | .use_no .on_off .open_img{ 41 | width: 36rpx; 42 | height: 36rpx; 43 | vertical-align: middle; 44 | } 45 | 46 | .use_no .on_off .off_img{ 47 | transform: rotate(-180deg); 48 | width: 36rpx; 49 | height: 36rpx; 50 | vertical-align: middle; 51 | } -------------------------------------------------------------------------------- /pages/help/eGuide.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | data: { 3 | 4 | } 5 | }) -------------------------------------------------------------------------------- /pages/help/eGuide.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/help/eGuide.wxml: -------------------------------------------------------------------------------- 1 | 2 | 微信卡包操作指引 3 | 4 | 1.顾客在微信平台(包括微信卡包、微信公众号)进行卡券购买、充值、余额查询、消费等操作时,应当严格遵守本指引,并自行承担违反本指引可能带来的风险。 5 | 2.通过扫描二维码或通过微信平台购买及充值礼品卡券,支付方式仅限微信支付。根据国家法律规定,顾客购卡或充值达到1万元或以上的,应当在微信平台办理实名登记,提供购卡人的姓名、有效身份证件号码及联系方式。 6 | 3.顾客可将通过微信购买卡券放入微信卡包。 7 | 4.终端消费者在品牌名门店购物时,可在移动终端上打开微信卡包,点击已购买卡券,打开电子支付码,收银员扫码即可完成支付。 8 | 5.顾客在微信品台购买的卡券券名为不记名卡,不可挂失,请自行妥善保管避免丢失或密码泄漏造损失。 9 | -------------------------------------------------------------------------------- /pages/help/eGuide.wxss: -------------------------------------------------------------------------------- 1 | /* pages/help/eGuide.wxss */ 2 | .guide_title{font-size: 28rpx; line-height: 40rpx; color: #333; text-align: center; margin-top: 40rpx;} 3 | .guide_con{padding: 20rpx 30rpx;} 4 | .guide_con .row{font-size: 28rpx; line-height: 40rpx; color: #333; padding: 10rpx 0;} -------------------------------------------------------------------------------- /pages/help/help.js: -------------------------------------------------------------------------------- 1 | // pages/help/help.js 2 | Page({ 3 | 4 | /** 5 | * 页面的初始数据 6 | */ 7 | data: { 8 | 9 | }, 10 | 11 | /** 12 | * 生命周期函数--监听页面加载 13 | */ 14 | onLoad: function (options) { 15 | 16 | }, 17 | 18 | /** 19 | * 生命周期函数--监听页面初次渲染完成 20 | */ 21 | onReady: function () { 22 | 23 | }, 24 | 25 | /** 26 | * 生命周期函数--监听页面显示 27 | */ 28 | onShow: function () { 29 | 30 | }, 31 | 32 | /** 33 | * 生命周期函数--监听页面隐藏 34 | */ 35 | onHide: function () { 36 | 37 | }, 38 | 39 | /** 40 | * 生命周期函数--监听页面卸载 41 | */ 42 | onUnload: function () { 43 | 44 | }, 45 | 46 | /** 47 | * 页面相关事件处理函数--监听用户下拉动作 48 | */ 49 | onPullDownRefresh: function () { 50 | 51 | }, 52 | 53 | /** 54 | * 页面上拉触底事件的处理函数 55 | */ 56 | onReachBottom: function () { 57 | 58 | }, 59 | 60 | /** 61 | * 用户点击右上角分享 62 | */ 63 | onShareAppMessage: function () { 64 | 65 | } 66 | }) -------------------------------------------------------------------------------- /pages/help/help.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/help/help.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.填写资料免费办理会员卡 4 | 2.会员个人资料变更保存后无法修改 5 | 3.VIP卡不得转借他人使用,非卡主本人用卡我司有权拒绝使用 6 | 4.会员生日可享受免费礼品 7 | 5.积分专项礼品,1万积分可兑换100元礼品 8 | 6.更多会员活动请关注微信公众号 9 | 10 | -------------------------------------------------------------------------------- /pages/help/help.wxss: -------------------------------------------------------------------------------- 1 | /* pages/help/help.wxss */ 2 | .help_center{padding: 30rpx;} 3 | .help_center .row{font-size: 28rpx; line-height: 40rpx; margin-top: 15rpx;} -------------------------------------------------------------------------------- /pages/index/index.js: -------------------------------------------------------------------------------- 1 | //index.js 2 | //获取应用实例 3 | const app = getApp() 4 | 5 | Page({ 6 | data: { 7 | motto: 'Hello World', 8 | userInfo: {}, 9 | hasUserInfo: false, 10 | canIUse: wx.canIUse('button.open-type.getUserInfo') 11 | }, 12 | //事件处理函数 13 | bindViewTap: function() { 14 | wx.navigateTo({ 15 | url: '../logs/logs' 16 | }) 17 | }, 18 | onLoad: function () { 19 | if (app.globalData.userInfo) { 20 | this.setData({ 21 | userInfo: app.globalData.userInfo, 22 | hasUserInfo: true 23 | }) 24 | } else if (this.data.canIUse){ 25 | // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 26 | // 所以此处加入 callback 以防止这种情况 27 | app.userInfoReadyCallback = res => { 28 | this.setData({ 29 | userInfo: res.userInfo, 30 | hasUserInfo: true 31 | }) 32 | } 33 | } else { 34 | // 在没有 open-type=getUserInfo 版本的兼容处理 35 | wx.getUserInfo({ 36 | success: res => { 37 | app.globalData.userInfo = res.userInfo 38 | this.setData({ 39 | userInfo: res.userInfo, 40 | hasUserInfo: true 41 | }) 42 | } 43 | }) 44 | } 45 | }, 46 | getUserInfo: function(e) { 47 | console.log(e) 48 | app.globalData.userInfo = e.detail.userInfo 49 | this.setData({ 50 | userInfo: e.detail.userInfo, 51 | hasUserInfo: true 52 | }) 53 | } 54 | }) 55 | -------------------------------------------------------------------------------- /pages/index/index.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | } -------------------------------------------------------------------------------- /pages/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{userInfo.nickName}} 8 | 9 | 10 | 11 | {{motto}} 12 | 13 | 14 | -------------------------------------------------------------------------------- /pages/index/index.wxss: -------------------------------------------------------------------------------- 1 | /**index.wxss**/ 2 | .userinfo { 3 | display: flex; 4 | flex-direction: column; 5 | align-items: center; 6 | } 7 | 8 | .userinfo-avatar { 9 | width: 128rpx; 10 | height: 128rpx; 11 | margin: 20rpx; 12 | border-radius: 50%; 13 | } 14 | 15 | .userinfo-nickname { 16 | color: #aaa; 17 | } 18 | 19 | .usermotto { 20 | margin-top: 200px; 21 | } -------------------------------------------------------------------------------- /pages/memberShip/myVip.js: -------------------------------------------------------------------------------- 1 | // pages/memberShip/myVip.js 2 | var app = getApp(); 3 | Page({ 4 | 5 | /** 6 | * 页面的初始数据 7 | */ 8 | data: { 9 | card: {}, 10 | swiperCurrent: 0 //当前正在显示的 swiper index 11 | }, 12 | obj: { }, 13 | 14 | /** 15 | * 生命周期函数--监听页面加载 16 | */ 17 | onLoad: function (options) { 18 | this.obj.spid = options.spid; 19 | this.loadData(); 20 | }, 21 | 22 | /** 23 | * 生命周期函数--监听页面初次渲染完成 24 | */ 25 | onReady: function () { 26 | 27 | }, 28 | 29 | //swiper滚动时触发 30 | swiperChange: function (e) { 31 | this.setData({ 32 | swiperCurrent: e.detail.current 33 | }) 34 | }, 35 | 36 | loadData: function () { 37 | var that = this; 38 | if(!this.obj.spid) { 39 | wx.showModal({ 40 | title: '出错了', 41 | content: '无法获取用户会员卡信息', 42 | showCancel: false 43 | }); 44 | return; 45 | } 46 | wx.showLoading({ 47 | title: '加载中', 48 | mask: true, 49 | success: function () { 50 | app.request({ 51 | url: '/user/card/level', 52 | data: { 53 | spid: that.obj.spid 54 | }, 55 | success: function (res) { 56 | if (res.data.data) { 57 | var swiperCurrent = this.data.swiperCurrent; 58 | var data = res.data.data; 59 | for (var i = 0;i < data.list.length;i++) { 60 | var fi = data.list[i]; 61 | if(data.currentLevel === fi.level){ 62 | swiperCurrent = i; 63 | } 64 | 65 | if(!fi.defaultUpLevelCondition && (data.upType === 1 || data.upType === 2)){ 66 | fi.upLevelCondition = parseInt(fi.upLevelCondition, 10).toFixed(2); 67 | } 68 | } 69 | that.setData({ 70 | swiperCurrent:swiperCurrent, 71 | card: res.data.data 72 | }); 73 | } 74 | }, 75 | complete: function (res) { 76 | wx.hideLoading(); 77 | } 78 | }); 79 | } 80 | }); 81 | } 82 | }); -------------------------------------------------------------------------------- /pages/memberShip/myVip.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/memberShip/myVip.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | {{item.levelName}} 13 | {{card.cardId}} 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 下一个等级:{{ (card.list && card.list.length - 1 > swiperCurrent && card.list[swiperCurrent+1].levelName) || '无' }} 30 | 31 | 32 | {{card.list[swiperCurrent].defaultUpLevelCondition}} 33 | 34 | 35 | 累计消费金额满{{ card.list[swiperCurrent].upLevelCondition || '0' }}元可升到本级 36 | 累计充值金额满{{ card.list[swiperCurrent].upLevelCondition || '0' }}元升到本级 37 | 累计获取积分满{{ card.list[swiperCurrent].upLevelCondition || '0' }}可升到本级 38 | - 39 | 40 | 41 | 42 | 43 | 44 | 权益简介 45 | {{card.list[swiperCurrent].levelName || '暂无说明'}} 46 | 47 | 48 | 会员权益 49 | 基本权益 50 | {{card.list[swiperCurrent].levelBaseRights || '暂无说明'}} 51 | 附加权益 52 | {{card.list[swiperCurrent].levelAttachRights || '暂无说明'}} 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /pages/memberShip/myVip.wxss: -------------------------------------------------------------------------------- 1 | /* pages/memberShip/myVip.wxss */ 2 | .vip_selector_wrap{background:#ffffff;height:480rpx;} 3 | .vip_swiper_wrap{padding-top:40rpx;position:relative;} 4 | .vip_swiper{height:348rpx;text-align: center;} 5 | .vip_swiper image {height: 100%;width: 580rpx;border-radius:20rpx;box-shadow: 0 0 6px rgba(0,0,0,0.4);} 6 | .vip_swiper swiper-item{position:relative;} 7 | .vip_swiper swiper-item .card_name{position:absolute;left:50rpx;bottom:53rpx;font-size:20rpx;color:#ffffff;letter-spacing: 5rpx} 8 | .vip_swiper swiper-item .card_num{position:absolute;left:50rpx;bottom:25rpx;font-size:20rpx;color:#ffffff;letter-spacing: 5rpx} 9 | 10 | .dot_list{position:absolute;left:0;right:0;bottom:-32rpx;display:-webkit-box;-webkit-box-pack: center;} 11 | .dot_list .dot{margin:0 8rpx;width:16rpx;height:16rpx;border-radius:16rpx;background:rgba(0,0,0,0.4);transition: all .6s;} 12 | .dot_list .dot.on{background:#3484F5;} 13 | 14 | .vip_detail_wrap{ 15 | position:absolute;bottom:0;left:0rpx;right:0rpx;top:455rpx;background:#ffffff; 16 | overflow: auto; 17 | } 18 | .vip_detail_title{ 19 | text-align: center;margin:0rpx 0 65rpx 0; 20 | } 21 | .vip_title_left{font-size:32rpx;} 22 | .vip_title_right{font-size:28rpx;color:#999999;margin-top:16rpx;} 23 | .vip_detail_cont{overflow: auto;padding-bottom:40rpx;} 24 | 25 | .text_list{font-size:28rpx;text-align:center;margin-bottom:55rpx;} 26 | .text_list:last-child{margin-bottom:0;} 27 | .text_list .text_title{ 28 | font-size:32rpx; 29 | margin-bottom:16rpx;position:relative;display:inline-block;background:#ffffff; 30 | } 31 | .text_list .text_title text{padding:0 60rpx;z-index:2;position:relative;background:#ffffff;} 32 | .text_list .text_title:after{ 33 | content:"";position:absolute;z-index:0;top:50%;left:-100rpx;right:-100rpx;height:2rpx;background:#E4E4E4; 34 | } 35 | .text_list .text_p{margin:4rpx auto 4rpx auto;font-size:24rpx;color:#999999;width:540rpx;} 36 | .text_list .text_p.grey{color:#999999;margin-bottom:10rpx;} -------------------------------------------------------------------------------- /pages/records/pointsList.js: -------------------------------------------------------------------------------- 1 | // pages/records/pointsList.js 2 | var app = getApp(); 3 | Page({ 4 | 5 | /** 6 | * 页面的初始数据 7 | */ 8 | data: { 9 | bonus:null 10 | }, 11 | obj: { 12 | currentPage: 1, 13 | hasNext: true, 14 | loading: false 15 | }, 16 | 17 | /** 18 | * 生命周期函数--监听页面加载 19 | */ 20 | onLoad: function (options) { 21 | this.obj.spid = decodeURIComponent(options.spid); 22 | this.obj.cardId = decodeURIComponent(options.cardId); 23 | }, 24 | 25 | /** 26 | * 生命周期函数--监听页面初次渲染完成 27 | */ 28 | onReady: function () { 29 | 30 | }, 31 | 32 | /** 33 | * 生命周期函数--监听页面显示 34 | */ 35 | onShow: function () { 36 | this.loadData(); 37 | }, 38 | 39 | /** 40 | * 生命周期函数--监听页面隐藏 41 | */ 42 | onHide: function () { 43 | 44 | }, 45 | 46 | /** 47 | * 生命周期函数--监听页面卸载 48 | */ 49 | onUnload: function () { 50 | 51 | }, 52 | 53 | /** 54 | * 页面相关事件处理函数--监听用户下拉动作 55 | */ 56 | onPullDownRefresh: function () { 57 | var that = this; 58 | that.obj.currentPage = 1; 59 | that.obj.hasNext = true; 60 | that.loadData(); 61 | }, 62 | 63 | /** 64 | * 页面上拉触底事件的处理函数 65 | */ 66 | onReachBottom: function () { 67 | if (this.obj.hasNext) { 68 | this.loadData(); 69 | } 70 | }, 71 | 72 | /** 73 | * 用户点击右上角分享 74 | */ 75 | onShareAppMessage: function () { 76 | 77 | }, 78 | 79 | loadData: function () { 80 | var that = this; 81 | if(!this.obj.spid || !this.obj.cardId) { 82 | wx.showModal({ 83 | title: '出错了', 84 | content: '无法获取会员卡信息', 85 | showCancel: false 86 | }); 87 | } 88 | console.log(that.obj.loading) 89 | if (that.obj.hasNext && !that.obj.loading) { 90 | wx.showNavigationBarLoading(); 91 | that.obj.loading = true; 92 | var currentPage = that.obj.currentPage; 93 | wx.showLoading({ 94 | title: '加载中', 95 | mask: true, 96 | success: function () { 97 | app.request({ 98 | url: '/user/card/bonus', 99 | data: { 100 | spid: that.obj.spid, 101 | currentPage: currentPage, 102 | pageSize: 10 103 | }, 104 | success: function (res) { 105 | var update = that.data.bonus; 106 | var bonus = res.data.data; 107 | if (bonus && bonus.dataList && bonus.dataList.length > 0) { 108 | if (currentPage <= 1) { 109 | update = bonus; 110 | } else { 111 | update.dataList = update.dataList.concat(bonus.dataList); 112 | } 113 | that.obj.currentPage = currentPage + 1; 114 | } 115 | 116 | if ((bonus.offset + 1) * bonus.limit >= bonus.total) { 117 | that.obj.hasNext = false; 118 | } 119 | that.setData({ 120 | bonus:update 121 | }); 122 | }, 123 | complete: function (res) { 124 | wx.hideLoading(); 125 | wx.hideNavigationBarLoading(); 126 | wx.stopPullDownRefresh(); 127 | that.obj.loading = false; 128 | } 129 | }); 130 | } 131 | }); 132 | } 133 | } 134 | }); -------------------------------------------------------------------------------- /pages/records/pointsList.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": true 3 | } -------------------------------------------------------------------------------- /pages/records/pointsList.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 当前剩余积分 {{bonus.bonus || 0}} 4 | 总消费积分 {{bonus.consumeTotalBonus || 0}} 5 | 6 | 7 | 8 | 9 | 开卡积分 10 | 充值积分 11 | 消费积分 12 | 接口开卡积分 13 | 接口充值积分 14 | - 15 | {{item.tradeTime}} 16 | 17 | -{{item.bonus}} 18 | +{{item.bonus}} 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /pages/records/pointsList.wxss: -------------------------------------------------------------------------------- 1 | /* pages/records/pointsList.wxss */ 2 | .bg_white{ 3 | background: #fff; 4 | height: 100%; 5 | position:absolute;left:0;top:0;bottom:0;right:0; 6 | 7 | } 8 | .bg_white_title{ 9 | background: #f8f8f8; 10 | padding: 30rpx 30rpx 15rpx 30rpx; 11 | } 12 | .bg_white text{ 13 | font-size: 24rpx; 14 | color: #999; 15 | line-height: 34rpx; 16 | } 17 | .bg_white text.title_num{ 18 | margin-left:50rpx; 19 | } 20 | .view_list{ 21 | padding: 0rpx 30rpx; 22 | } 23 | .view_li{ 24 | display: -webkit-box;padding: 20rpx 7rpx;border-bottom: 2rpx solid #E4E4E4; 25 | } 26 | .view_list_left{ 27 | -webkit-box-flex: 1;text-align: left; 28 | } 29 | .view_list_right{ 30 | font-size: 34rpx; 31 | color: #E94F4F; 32 | margin: 30rpx 58rpx 0 0; 33 | } 34 | .view_list_left .left_top { 35 | font-size: 28rpx; 36 | color: #333; 37 | line-height: 40rpx; 38 | } 39 | .view_list_left .left_bottom{ 40 | font-size: 24rpx; 41 | color: #999; 42 | line-height: 32rpx; 43 | margin-top: 6rpx; 44 | } 45 | .view_list{ 46 | padding: 0rpx 30rpx;background: #fff; 47 | } -------------------------------------------------------------------------------- /pages/records/transactionDetail.js: -------------------------------------------------------------------------------- 1 | // pages/records/transactionDetail.js 2 | var app = getApp(); 3 | Page({ 4 | 5 | /** 6 | * 页面的初始数据 7 | */ 8 | data: { 9 | // nowMoney: '+1100.00元', 10 | // tranState: '充值成功', 11 | // memberNum: '82347192347195619287137', 12 | // tranTime: '2017- 12 - 29 18: 28:41', 13 | // orderFrom: '线上充值', 14 | // orderCode: '2834762873475924582084763876', 15 | // payMoney: '0.01元', 16 | detail : {} 17 | }, 18 | 19 | /** 20 | * 生命周期函数--监听页面加载 21 | */ 22 | onLoad: function (options) { 23 | var tradeId = decodeURIComponent(options.tradeId); 24 | var spid = decodeURIComponent(options.spid); 25 | this.loadData(spid, tradeId); 26 | }, 27 | 28 | /** 29 | * 生命周期函数--监听页面初次渲染完成 30 | */ 31 | onReady: function () { 32 | 33 | }, 34 | 35 | /** 36 | * 生命周期函数--监听页面显示 37 | */ 38 | onShow: function () { 39 | 40 | }, 41 | 42 | /** 43 | * 生命周期函数--监听页面隐藏 44 | */ 45 | onHide: function () { 46 | 47 | }, 48 | 49 | /** 50 | * 生命周期函数--监听页面卸载 51 | */ 52 | onUnload: function () { 53 | 54 | }, 55 | 56 | /** 57 | * 页面相关事件处理函数--监听用户下拉动作 58 | */ 59 | onPullDownRefresh: function () { 60 | 61 | }, 62 | 63 | /** 64 | * 页面上拉触底事件的处理函数 65 | */ 66 | onReachBottom: function () { 67 | 68 | }, 69 | 70 | /** 71 | * 用户点击右上角分享 72 | */ 73 | onShareAppMessage: function () { 74 | 75 | }, 76 | 77 | loadData: function (spid, tradeId) { 78 | var that = this; 79 | if(!spid || !tradeId) { 80 | wx.showModal({ 81 | title: '出错了', 82 | content: '无法获取交易信息', 83 | showCancel: false 84 | }); 85 | } 86 | wx.showLoading({ 87 | title: '加载中', 88 | mask: true, 89 | success: function () { 90 | app.request({ 91 | url: '/user/card/transaction', 92 | data: { 93 | spid: spid, 94 | listid: tradeId 95 | }, 96 | success: function (res) { 97 | that.setData({ 98 | detail:res.data.data 99 | }); 100 | }, 101 | complete: function () { 102 | wx.hideLoading(); 103 | } 104 | }); 105 | } 106 | }); 107 | } 108 | }); -------------------------------------------------------------------------------- /pages/records/transactionDetail.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/records/transactionDetail.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 交易详情 5 | {{nowMoney}} 6 | 7 | 8 | 9 | 交易状态 10 | 待支付 11 | 支付成功 12 | 支付失败 13 | 交易成功 14 | 交易失败 15 | 废弃 16 | {{tranState}} 17 | 18 | 19 | 会员卡号 20 | {{detail.cardId}} 21 | 22 | 23 | 交易时间 24 | {{detail.tradeTimeFormat}} 25 | 26 | 27 | 订单来源 28 | 购卡 29 | 充值 30 | 核销 31 | 赠送 32 | 转赠开卡 33 | 退款开卡 34 | 扣款 35 | 第三方支付 36 | 线下退款 37 | - 38 | 39 | 40 | 订单号 41 | {{detail.posOutTradeNo}} 42 | 43 | 44 | 支付金额 45 | ¥{{detail.payAmount}} 46 | 47 | 48 | 交易金额 49 | ¥{{detail.tradeAmount}} 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /pages/records/transactionDetail.wxss: -------------------------------------------------------------------------------- 1 | /* pages/records/transactionDetail.wxss */ 2 | .list{ 3 | background: #fff; 4 | padding: 30rpx 30rpx 24rpx 30rpx; 5 | } 6 | .list_title{ 7 | display: -webkit-box; 8 | padding: 5rpx 3rpx 21rpx 3rpx; 9 | border-bottom: 2rpx solid #E4E4E4; 10 | line-height: 50rpx; 11 | } 12 | .list_title .title{ 13 | display:block; 14 | -webkit-box-flex: 1; 15 | text-align: left; 16 | font-size: 36rpx; 17 | color: #000; 18 | } 19 | .list_title .title_num{ 20 | display: block; 21 | -webkit-box-flex: 1; 22 | text-align: right; 23 | font-size: 38rpx; 24 | color: #000; 25 | } 26 | .detail_bg{ 27 | padding-top: 15rpx; 28 | } 29 | .detail_list{ 30 | display: -webkit-box; 31 | padding: 0rpx 3rpx; 32 | line-height: 56rpx; 33 | } 34 | .detail_list .left{ 35 | display:block; 36 | -webkit-box-flex: 1; 37 | text-align: left; 38 | font-size: 28rpx; 39 | color: #999; 40 | } 41 | .detail_list .right{ 42 | display: block; 43 | -webkit-box-flex: 1; 44 | text-align: right; 45 | font-size: 28rpx; 46 | color: #999; 47 | } -------------------------------------------------------------------------------- /pages/records/transactionList.js: -------------------------------------------------------------------------------- 1 | // pages/records/transactionList.js 2 | var app = getApp(); 3 | Page({ 4 | 5 | /** 6 | * 页面的初始数据 7 | */ 8 | data: { 9 | trade:{ 10 | cardItem:{}, 11 | tradeList:[] 12 | } 13 | }, 14 | obj: { 15 | currentPage: 1, 16 | hasNext: true, 17 | loading: false 18 | }, 19 | 20 | jumpDetail: function (e) { 21 | var id = e.currentTarget.dataset.id; 22 | wx.navigateTo({ 23 | url: '/pages/records/transactionDetail?spid=' + this.obj.spid + '&tradeId=' + id 24 | }); 25 | }, 26 | 27 | /** 28 | * 生命周期函数--监听页面加载 29 | */ 30 | onLoad: function (options) { 31 | this.obj.spid = decodeURIComponent(options.spid); 32 | this.obj.cardId = decodeURIComponent(options.cardId); 33 | }, 34 | 35 | /** 36 | * 生命周期函数--监听页面初次渲染完成 37 | */ 38 | onReady: function () { 39 | 40 | }, 41 | 42 | /** 43 | * 生命周期函数--监听页面显示 44 | */ 45 | onShow: function () { 46 | this.loadData(); 47 | }, 48 | 49 | /** 50 | * 生命周期函数--监听页面隐藏 51 | */ 52 | onHide: function () { 53 | 54 | }, 55 | 56 | /** 57 | * 生命周期函数--监听页面卸载 58 | */ 59 | onUnload: function () { 60 | 61 | }, 62 | 63 | /** 64 | * 页面相关事件处理函数--监听用户下拉动作 65 | */ 66 | onPullDownRefresh: function () { 67 | var that = this; 68 | that.obj.currentPage = 1; 69 | that.obj.hasNext = true; 70 | that.loadData(); 71 | }, 72 | 73 | /** 74 | * 页面上拉触底事件的处理函数 75 | */ 76 | onReachBottom: function () { 77 | if (this.obj.hasNext) { 78 | this.loadData(); 79 | } 80 | }, 81 | 82 | /** 83 | * 用户点击右上角分享 84 | */ 85 | onShareAppMessage: function () { 86 | 87 | }, 88 | 89 | loadData: function () { 90 | var that = this; 91 | if(!this.obj.spid || !this.obj.cardId) { 92 | wx.showModal({ 93 | title: '出错了', 94 | content: '无法获取会员卡信息', 95 | showCancel: false 96 | }); 97 | return; 98 | } 99 | if (that.obj.hasNext && !that.obj.loading) { 100 | wx.showNavigationBarLoading(); 101 | that.obj.loading = true; 102 | var currentPage = that.obj.currentPage; 103 | wx.showLoading({ 104 | title: '加载中', 105 | mask: true, 106 | success: function () { 107 | app.request({ 108 | url: '/user/card/transactions', 109 | data: { 110 | spid: that.obj.spid, 111 | currentPage: currentPage, 112 | pageSize: 10 113 | }, 114 | success: function (res) { 115 | var update = that.data.trade; 116 | var trade = res.data.data; 117 | if (trade && trade.tradeList && trade.tradeList.length > 0) { 118 | if (currentPage <= 1) { 119 | update = trade; 120 | } else { 121 | update.tradeList = update.tradeList.concat(trade.tradeList); 122 | } 123 | that.obj.currentPage = currentPage + 1; 124 | } 125 | 126 | if ((trade.offset + 1) * trade.limit >= trade.total) { 127 | that.obj.hasNext = false; 128 | } 129 | that.setData({ 130 | trade:update 131 | }); 132 | }, 133 | complete: function (res) { 134 | wx.hideLoading(); 135 | wx.hideNavigationBarLoading(); 136 | wx.stopPullDownRefresh(); 137 | that.obj.loading = false; 138 | } 139 | }); 140 | } 141 | }); 142 | } 143 | } 144 | }); -------------------------------------------------------------------------------- /pages/records/transactionList.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": true 3 | } -------------------------------------------------------------------------------- /pages/records/transactionList.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 当前余额 ¥{{trade.cardItem.balance || '0.00'}} 5 | 累计消费金额 ¥{{trade.cardItem.consumeTotal || '0.00'}} 6 | 7 | 8 | 9 | 10 | 购卡 11 | 充值 12 | 核销 13 | 赠送 14 | 转赠开卡 15 | 退款开卡 16 | 扣款 17 | 第三方支付 18 | 线下退款 19 | - 20 | {{item.tradeTimeFormat}} 21 | 22 | +¥{{item.tradeAmount}} 23 | -¥{{item.tradeAmount}} 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /pages/records/transactionList.wxss: -------------------------------------------------------------------------------- 1 | /* pages/records/transactionList.wxss */ 2 | .bg_white{ 3 | background: #fff; 4 | height: 100%; 5 | position:absolute;left:0;top:0;bottom:0;right:0; 6 | 7 | } 8 | .bg_white_title{ 9 | background: #f8f8f8; 10 | padding: 30rpx 30rpx 15rpx 30rpx; 11 | } 12 | .bg_white text{ 13 | font-size: 24rpx; 14 | color: #999; 15 | line-height: 34rpx; 16 | } 17 | .bg_white text.title_num{ 18 | margin-left:50rpx; 19 | } 20 | .view_list{ 21 | padding: 0rpx 30rpx; 22 | } 23 | .view_li{ 24 | display: -webkit-box;padding: 20rpx 7rpx;border-bottom: 2rpx solid #E4E4E4; 25 | } 26 | .view_list_left{ 27 | -webkit-box-flex: 1;text-align: left; 28 | } 29 | .view_list_right{ 30 | font-size: 34rpx; 31 | color: #E94F4F; 32 | margin: 30rpx 58rpx 0 0; 33 | } 34 | .view_list_left .left_top { 35 | font-size: 28rpx; 36 | color: #333; 37 | line-height: 40rpx; 38 | } 39 | .view_list_left .left_bottom{ 40 | font-size: 24rpx; 41 | color: #999; 42 | line-height: 32rpx; 43 | margin-top: 6rpx; 44 | } 45 | .view_list{ 46 | padding: 0rpx 30rpx;background: #fff; 47 | } -------------------------------------------------------------------------------- /pages/redirect/redirect.js: -------------------------------------------------------------------------------- 1 | // pages/card/cardDetail.js 2 | var app = getApp(); 3 | Page({ 4 | 5 | obj : { 6 | 'coupons' : '/pages/coupons/couponListViewOnly', 7 | 'points' : '/pages/records/pointsList', 8 | 'transactions' : '/pages/records/transactionList', 9 | 'vip' : '/pages/memberShip/myVip', 10 | 'recharge' : '/pages/topup/topup', 11 | 'pay' : '/pages/topup/pay', 12 | 'detail' : '/pages/card/cardDetail', 13 | 'center' : '/pages/card/cardIndex' 14 | }, 15 | 16 | /** 17 | * 生命周期函数--监听页面加载 18 | */ 19 | onLoad: function (options) { 20 | this.options = options; 21 | }, 22 | 23 | /** 24 | * 生命周期函数--监听页面初次渲染完成 25 | */ 26 | onReady: function () { 27 | 28 | }, 29 | 30 | /** 31 | * 生命周期函数--监听页面显示 32 | */ 33 | onShow: function () { 34 | var scene = this.options.scene || ''; 35 | if(scene) { 36 | wx.showLoading({ 37 | title: '加载中', 38 | mask: true, 39 | success: function () { 40 | wx.redirectTo({ 41 | url: '/pages/card/cardDetail?spid=' + scene, 42 | success:function () { 43 | wx.hideLoading(); 44 | } 45 | }); 46 | } 47 | }); 48 | 49 | } else { 50 | var p = this.options.p; 51 | if(!p || !this.obj[p]){ 52 | p = 'detail'; 53 | // wx.showLoading({ 54 | // title: '加载中', 55 | // mask: true, 56 | // success: function () { 57 | // wx.redirectTo({ 58 | // url: '/pages/card/cardIndex', 59 | // success:function () { 60 | // wx.hideLoading(); 61 | // } 62 | // }); 63 | // } 64 | // }); 65 | // return; 66 | } 67 | 68 | var that = this; 69 | if(!that.options.card_id || !that.options.encrypt_code){ 70 | wx.showModal({ 71 | title: '出错了', 72 | content: '无效的参数,请重试', 73 | showCancel: false 74 | }); 75 | return; 76 | } 77 | 78 | wx.showLoading({ 79 | title: '加载中', 80 | mask: true, 81 | success: function () { 82 | app.request({ 83 | url: '/user/card/wechat/decrypt', 84 | data: { 85 | wxCardId:that.options.card_id, 86 | encryptCode: that.options.encrypt_code 87 | }, 88 | success: function (res) { 89 | console.log(res.data) 90 | if(res.data.data.spid && res.data.data.code){ 91 | wx.redirectTo({ 92 | url: '/pages/card/cardDetail?spid=' + res.data.data.spid + '&redirect=' + that.obj[p] + '&cardId=' + res.data.data.code 93 | }); 94 | } else { 95 | wx.showModal({ 96 | title: '出错了', 97 | content: '无效的参数,请重试', 98 | showCancel: false 99 | }); 100 | } 101 | }, 102 | complete: function (res) { 103 | wx.hideLoading(); 104 | } 105 | }); 106 | 107 | } 108 | }); 109 | } 110 | }, 111 | 112 | /** 113 | * 生命周期函数--监听页面隐藏 114 | */ 115 | onHide: function () { 116 | 117 | }, 118 | 119 | /** 120 | * 生命周期函数--监听页面卸载 121 | */ 122 | onUnload: function () { 123 | 124 | }, 125 | 126 | /** 127 | * 页面相关事件处理函数--监听用户下拉动作 128 | */ 129 | onPullDownRefresh: function () { 130 | 131 | }, 132 | 133 | /** 134 | * 页面上拉触底事件的处理函数 135 | */ 136 | onReachBottom: function () { 137 | 138 | }, 139 | 140 | /** 141 | * 用户点击右上角分享 142 | */ 143 | onShareAppMessage: function () { 144 | 145 | }, 146 | 147 | loadData: function () { 148 | 149 | } 150 | }); -------------------------------------------------------------------------------- /pages/redirect/redirect.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/redirect/redirect.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pages/topup/pay.js: -------------------------------------------------------------------------------- 1 | // pages/topup/pay.js 2 | var app = getApp(); 3 | var wxbarcode = require('../../utils/code'); 4 | 5 | Page({ 6 | 7 | /** 8 | * 页面的初始数据 9 | */ 10 | data: { 11 | loading:true, 12 | card:{} 13 | }, 14 | obj:{ 15 | refresh:true 16 | }, 17 | 18 | /** 19 | * 生命周期函数--监听页面加载 20 | */ 21 | onLoad: function (options) { 22 | this.obj.spid = decodeURIComponent(options.spid); 23 | this.obj.cardId = decodeURIComponent(options.cardId); 24 | }, 25 | 26 | /** 27 | * 生命周期函数--监听页面初次渲染完成 28 | */ 29 | onReady: function () { 30 | 31 | }, 32 | 33 | /** 34 | * 生命周期函数--监听页面显示 35 | */ 36 | onShow: function () { 37 | wx.setStorageSync('page_cardindex', true); 38 | wx.setStorageSync('page_carddetail', true); 39 | this.loadData(); 40 | }, 41 | 42 | /** 43 | * 生命周期函数--监听页面隐藏 44 | */ 45 | onHide: function () { 46 | 47 | }, 48 | 49 | /** 50 | * 生命周期函数--监听页面卸载 51 | */ 52 | onUnload:function () { 53 | var timer = this.obj.timer; 54 | if (timer) { 55 | clearTimeout(timer); 56 | } 57 | }, 58 | 59 | /** 60 | * 页面相关事件处理函数--监听用户下拉动作 61 | */ 62 | onPullDownRefresh: function () { 63 | 64 | }, 65 | 66 | /** 67 | * 页面上拉触底事件的处理函数 68 | */ 69 | onReachBottom: function () { 70 | 71 | }, 72 | 73 | /** 74 | * 用户点击右上角分享 75 | */ 76 | onShareAppMessage: function () { 77 | 78 | }, 79 | 80 | jumpToRecharge : function () { 81 | wx.navigateTo({ 82 | url: '/pages/topup/topup?spid=' + this.obj.spid + '&cardId=' + this.obj.cardId 83 | }); 84 | }, 85 | 86 | jumpToTradeList : function () { 87 | wx.navigateTo({ 88 | url: '/pages/records/transactionList?spid=' + this.obj.spid + '&cardId=' + this.obj.cardId 89 | }); 90 | }, 91 | 92 | handleRefreshCode:function () { 93 | if(!this.data.loading){ 94 | this.loadData(); 95 | } 96 | }, 97 | 98 | handleAutoRefreshCode:function () { 99 | var that = this; 100 | var timer = that.obj.timer; 101 | if (timer) { 102 | clearTimeout(timer); 103 | } 104 | that.obj.timer = setTimeout(function () { 105 | that.loadData(); 106 | }, 60000); 107 | }, 108 | 109 | loadData:function () { 110 | var that = this; 111 | if (!this.obj.spid || !this.obj.cardId) { 112 | wx.showModal({ 113 | title: '出错了', 114 | content: '无法获取会员卡信息', 115 | showCancel: false 116 | }); 117 | return; 118 | } 119 | that.obj.loading = true; 120 | that.setData({ 121 | loading:true 122 | }); 123 | wx.showLoading({ 124 | title: '加载中', 125 | mask: true, 126 | success: function () { 127 | app.request({ 128 | url: '/user/card/consume/code', 129 | data: { 130 | spid: that.obj.spid, 131 | cardId: that.obj.cardId 132 | }, 133 | success: function (res) { 134 | if (res.data.data){ 135 | var card = res.data.data; 136 | card.balance = parseFloat(card.balance).toFixed(2); 137 | card.flag = parseInt(card.balance * 100, 10) > 0; 138 | var ottCode = card.ottCode; 139 | if(card.flag && card.ottCode){ 140 | card.ottCode = card.ottCode.replace(/(.{4})/g, "$1 ") 141 | } 142 | that.setData({ 143 | loading:false, 144 | card 145 | }); 146 | if(card.flag){ 147 | wxbarcode.barcode('barcode', ottCode, 550, 170); 148 | wxbarcode.qrcode('qrcode', card.link, 300, 300); 149 | } else { 150 | that.obj.refresh = false; 151 | } 152 | } 153 | }, 154 | complete: function () { 155 | wx.hideLoading(); 156 | that.obj.loading = false; 157 | if(that.obj.refresh){ 158 | that.handleAutoRefreshCode(); 159 | } 160 | that.setData({ 161 | loading:false 162 | }); 163 | } 164 | }); 165 | } 166 | }); 167 | } 168 | }); -------------------------------------------------------------------------------- /pages/topup/pay.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": { 3 | "List": "/components/List/List", 4 | "ListItem": "/components/List/ListItem" 5 | } 6 | } -------------------------------------------------------------------------------- /pages/topup/pay.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 余额不足,请先充值! 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | {{card.ottCode || ''}} 14 | 15 | 18 | 19 | 20 | 21 | 24 | 25 | 26 | 27 | 28 | 29 | {{card.cardName}} 30 | {{card.balance}} 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | {{ loading ? '加载中' : '每分钟自动更新,请当面使用勿泄漏' }} 40 | 41 | 42 | 交易明细 43 | 44 | 世明科技 45 | -------------------------------------------------------------------------------- /pages/topup/pay.wxss: -------------------------------------------------------------------------------- 1 | /* pages/topup/pay.wxss */ 2 | page{background:#3C4FA0;} 3 | .code_section{background:#ffffff;margin:30rpx;height:750rpx;border-radius:6rpx;box-shadow:0 0 1rpx rgba(0, 0, 0, 0.3);} 4 | .no_enough_balance{display:-webkit-box;-webkit-box-align: center;-webkit-box-pack: center;height:100%;} 5 | .non_enough_cont .no_enough_msg{font-size:28rpx;color:#999999;} 6 | .no_enough_btn{margin-top:23rpx;} 7 | 8 | .enough_balance{height:100%;position:relative;} 9 | .scan_number{font-size:28rpx;text-align:center;padding-top:38rpx;letter-spacing: 10rpx;} 10 | .scan_barcode{height:170rpx;text-align:center;padding:0 50rpx;margin-top:12rpx;} 11 | .scan_barcode image{height:170rpx;width:100%;} 12 | .scan_barcode canvas{height:170rpx;margin:0 auto;} 13 | .scan_qrcode{height:300rpx;text-align:center;margin-top:50rpx;} 14 | .scan_qrcode image{width:300rpx;height:300rpx;} 15 | .scan_qrcode canvas{width:300rpx;height:300rpx;margin:0 auto;} 16 | .scan_card_info{position:absolute;bottom:0;left:30rpx;right:30rpx;border-top:1rpx solid #E4E4E4;} 17 | 18 | .refresh_wrap{font-size:28rpx;text-align:center;color:#9DA7CF;} 19 | .refresh_wrap .btn_refresh{ 20 | display:inline-block;vertical-align: middle; 21 | width:30rpx;height:32rpx;margin-right:10rpx;position:relative;top:1rpx; 22 | } 23 | .refresh_wrap .btn_refresh image{width:30rpx;height:32rpx;vertical-align: top;} 24 | .refresh_wrap text{display:inline-block;vertical-align: middle;} 25 | .pay_detail{font-size:28rpx;color:#CED2E7;text-align:center;margin-top:87rpx;} 26 | .pay_detail image{width:13rpx;height:22rpx;margin-left:10rpx;} 27 | .provider{position:absolute;bottom:30rpx;left:0;right:0;text-align:center;font-size:24rpx;color:#353849;} -------------------------------------------------------------------------------- /pages/topup/topup.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": { 3 | "List": "/components/List/List", 4 | "ListItem": "/components/List/ListItem" 5 | } 6 | } -------------------------------------------------------------------------------- /pages/topup/topup.wxml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 17 | 18 | 请选择充值金额 19 | 20 | 21 | 22 | 23 | {{config.cardAmount1 || 0}}元 24 | 25 | 26 | 27 | {{config.cardAmount2 || 0}}元 28 | 29 | 30 | 31 | {{config.cardAmount3 || 0}}元 32 | 33 | 34 | 35 | {{config.cardAmount4 || 0}}元 36 | 37 | 38 | 39 | {{config.cardAmount5 || 0}}元 40 | 41 | 42 | 43 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 优惠券 55 | {{counponSeleccted.couponId?counponSeleccted.useCondition:'请选择优惠券'}} 56 | 57 | 58 | 积分抵扣金额 59 | {{config.bonusDeduction.costBonusUnit}}积分抵扣{{config.bonusDeduction.reduceMoney}}元 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 76 | 77 | 优惠券优惠 78 | +{{discount.discountCouponAmount}} 79 | -{{discount.discountCouponAmount}} 80 | 81 | 82 | {{config.levelName||''}}优惠 83 | +{{discount.discountRightAmount||'0.00'}} 84 | 85 | 86 | 满赠优惠 87 | 满减优惠 88 | 满折优惠 89 | +{{discount.discountActivityAmount||'0.00'}} 90 | -{{discount.discountActivityAmount||'0.00'}} 91 | 92 | 93 | 94 | 95 | 96 | 97 | 已阅读并同意《电子卡指引》 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /pages/topup/topup.wxss: -------------------------------------------------------------------------------- 1 | /* pages/topup/topup.wxss */ 2 | .card_activity{ 3 | display:-webkit-box; 4 | height: 80rpx; 5 | background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAABQBAMAAAC0bO3VAAAAIVBMVEXx8//g5P/d4P/Q1v/c3//r7f/u8P/X2//n6v/k5//Z3f+XXMbYAAAD60lEQVR42u3cz0vbYBgH8G+FN7S3WpyMnexL5qrXsA12a5b9sKdGHOhOVTbRXRUCnqxzA29d9gPZbVrw31y7Nd3T2NRFeF7b5PlcbQ598uXbl9Y8SKs9/9/uIRO29FjfYVJxPoUmMqCtE9wHPxr3fAW+N/YpGHwv7vkKfG/s0zD4XtxzFXhfT8T8/mjccxX4fZ3MblwFwUX1vAk2NO55CrzSybyroK/rufdb4EHjnqvAhzpRIwiOuq7r1s9s71cTLGjc8xT4bZ3oVXDk6j8WrbZXZxk8jXueAq9uHntfE3t2PVY1dx73WQ78SXLJkLHrGlC01zDi7uM+u4Ev6SQ2GXtPB9j3FkFMQdxnN/DhhJZxNbECYN3li5c/fyuLmEmT4t7VfTTw1sJrcFHzt9LCTEqO+9WR7okFvuQdg7j7wGcw7hc6pgPgdMoCn5m4V8/f7AK7b36SuJPAF72pavgZjXtRx50PAmTZP850XL9jvi2Di8pN3NfjiR6GuVAHVKhHPRz8gYufk7hbelT01VcUa6utR7UAy+6Ai8pJ3AuJv29YgxqPDb4MYOMl2Pi5iDtCTdVIegprg/mfXD9KMhaNykXclaaq9F1sLEfBr2iq2S+aJtj4eYj7TuywQiwcjz/y9G/HaRlsVA7ijjDxN1TlkgjGi2buBYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEJMKWXu/93VgTPQAZs5HVnCWIV6wiWrgbsEc3xjj3d8dSJPQBieu2V3xl9ydahNzl2ZivtbZ+gZCMNzx8br+CVR3I3OHb6ZuJccgkaOa+7LGK8Y3wCxE8Xd7NyVkbirS4egRWN67jhdGzP31eDC8Nzh88adljt/0RTIs++JgV+89ky93Y+7LsMkZSDuHxyCs2hKN889vlxpfbiCqQOjfPa4l5yYxyB45l5DEmthrTW6/60RHGrzc1fccbdIubMWDZ37yoQXefSmhMP9eh2Y5TPH/aND8BaN0pEqkm17ZGdBpREMFr01YZbijfs7h2AuGkV3myTzvfrn6Ipo7ObnDp8z7kWH4C4ai+4lmMDveiufdmG9P1v9t02yBcNUC2ys5844ZfCg29om2at4fzW67rCZsoSUu4miCckXBZNtftGeWz3fIJ/EGbLjjPcUPE7IAT7lKrIasoOUu5miWU8b35DcqOxQ7UvHaNHMkQNNyg/iJWTK3sKBwaIpkQNNyk2THWSM1X5lqmjoHMspV+8dI3v2wgMjRUN7o5ZyO/+srvW6wdYjI0VToYv0kpG1epk8vlMqvOQvmpNUxVHUmTxGXrP5gLtodvTQcspXZ5pqX7IWTUmnaY7KLY8zvwEOJ9MmHmxB6QAAAABJRU5ErkJggg==); 6 | background-size:100% 80rpx; 7 | padding: 20rpx 30rpx; 8 | box-sizing: border-box; 9 | } 10 | .card_activity .left{ 11 | -webkit-box-flex:1; 12 | display:block; 13 | opacity: 0.88; 14 | font-size: 28rpx; 15 | color: #4F5EFF; 16 | vertical-align: middle; 17 | overflow: hidden; 18 | text-overflow:ellipsis; 19 | white-space: nowrap; 20 | } 21 | 22 | .card_activity .right{ 23 | display: block; 24 | vertical-align: middle; 25 | } 26 | .card_activity .right .card_activity_img{ 27 | display: inline-block; 28 | margin-left: 10rpx; 29 | width: 36rpx; 30 | height: 36rpx; 31 | } 32 | .card_activity .right .card_right{ 33 | display: flex; 34 | justify-content:center; 35 | align-items:center; 36 | } 37 | .card_activity .right .card_right_img{ 38 | display: inline-block; 39 | margin-left: 10rpx; 40 | vertical-align: middle; 41 | width: 12rpx; 42 | height: 20rpx; 43 | } 44 | .listItem_desc{ 45 | display: inline-block; 46 | padding-left: 20rpx; 47 | font-size: 24rpx; 48 | color: #BBBBBB; 49 | letter-spacing: 1.71rpx; 50 | } 51 | 52 | .intergral_input{ 53 | display: inline-block; 54 | vertical-align:middle; 55 | width: 284rpx; 56 | height: 58rpx; 57 | border: 1rpx solid #4F5EFF; 58 | border-radius: 12rpx; 59 | color: #4F5EFF; 60 | } 61 | .card_title{height: 78rpx;border-bottom: 2rpx solid #E4E4E4;background:#ffffff;} 62 | .card_title .left{display: inline-block;padding:0 25rpx 0 30rpx;vertical-align: middle;} 63 | .card_title .left .card_title_img{width: 32rpx;height: 25rpx;} 64 | .card_title .right{line-height: 78rpx;font-size: 32rpx;color: #535353;} 65 | .card_wrap{padding:30rpx;clear:both;background:#ffffff;} 66 | .card_list{position:relative;display:inline-block;width:33.33%;vertical-align: top;} 67 | .card_list view,.card_list input{ 68 | text-align:center;margin-right:15rpx;margin-bottom:15rpx;font-size:34rpx; 69 | height:148rpx;line-height:148rpx;color:#333333; 70 | border:2rpx solid #D6DAFF;border-radius:10rpx;background:#ffffff; 71 | } 72 | .card_list:nth-child(3n+0) view,.card_list:nth-child(3n+0) input{margin-right:0;} 73 | .card_list view.on{color:#4F5EFF;border-color:#4F5EFF;} 74 | .card_list input.on{color:#4F5EFF;border-color:#4F5EFF;} 75 | .card_list .check_on{position: absolute;top: 0rpx;right: 0rpx;width: 44rpx;height: 44rpx; 76 | background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC0AAAAsCAMAAADGmMENAAAAS1BMVEUAAABQX/9RY/9PXv////9hb//j5v/Axf9WZP/X2v/Lz/+Vnv9zgP9odf9SYf/3+P/q7P/c3/+zuv9baf/w8f+gqP+Ikv+LlP98h/++kMglAAAAA3RSTlMA3Rza4SPDAAAA2UlEQVQ4y5XSWQ6DMAwE0GkxEPad9v4nbSwaFgmLzHw50lP84cH7lcQHFAfFEcnbvFIdx6dCxHNE8SYTkVx1BK9nj8tW9TNfO48L5ycY3OVNGBfxySYdcc/TQfp0G0dvwwP3vNDvVLhS8fxfhHteb9t1h09Xh+sYvFI11L1ovvstLZ7LnvW4vMVdFnB16onJm27Dy7lVNv+IZrx20ObjVo6LtnlbaDke9MHT0iW2fqwYKA6Kg+KgOCgOioPioDgoDoqD4qA4KA6Kg+KgOCgOioPioDgoDoqD4j/J/A5jnH6HPQAAAABJRU5ErkJggg==); 77 | background-size: 44rpx 44rpx; 78 | border:none; 79 | } 80 | .card_coupon{margin:20rpx 0;} 81 | .topup_check{line-height: 28rpx;font-size:28rpx;margin-top:30rpx;padding:0 30rpx;} 82 | 83 | .swift_checkbox{display:inline-block;border:1px solid #FAA122;border-radius: 50%; vertical-align:middle; width:24rpx;height:24rpx;overflow: hidden;font-size: 0rpx;} 84 | .swift_checkbox .swift_checkbox_img{width:24rpx;height:24rpx;} 85 | .swift_checkbox_txt{font-size: 20rpx;color: #999999;display:inline-block;margin-left:7rpx;vertical-align:middle;} 86 | 87 | .switch_wrap{ 88 | vertical-align: middle; 89 | width: 89rpx; 90 | height: 45rpx; 91 | } 92 | .switch_wrap .switch_img{ 93 | width: 89rpx; 94 | height: 45rpx; 95 | } 96 | -------------------------------------------------------------------------------- /pages/topup/topupDiscounts.js: -------------------------------------------------------------------------------- 1 | // pages/topup/topupDiscounts.js 2 | var app = getApp(); 3 | var util = require('../../utils/util.js'); 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | order:{} 11 | }, 12 | 13 | /** 14 | * 生命周期函数--监听页面加载 15 | */ 16 | onLoad: function (options) { 17 | this.obj.listid = decodeURIComponent(options.listid); 18 | this.obj.spid = decodeURIComponent(options.spid); 19 | this.initPage(); 20 | }, 21 | obj:{}, 22 | 23 | initPage:function(){ 24 | var that = this; 25 | if (!this.obj.listid || !this.obj.spid) { 26 | wx.showModal({ 27 | title: '出错了', 28 | content: '无法获取优惠信息', 29 | showCancel: false 30 | }); 31 | return; 32 | } 33 | 34 | // 获取优惠信息 35 | wx.showLoading({ 36 | title: '加载中', 37 | mask: true, 38 | success: function () { 39 | app.request({ 40 | url: '/user/card/recharge/queryDiscountAmountDetail', 41 | data: { 42 | listid: that.obj.listid, 43 | spid: that.obj.spid, 44 | }, 45 | success: function (res) { 46 | var discount = res.data.data; 47 | discount.discountAmount = util.formatFixed(discount.discountAmount); 48 | discount.couponDisAmountDesc && (discount.couponDisAmountDesc.discountAmount = util.formatFixed(discount.couponDisAmountDesc.discountAmount)); 49 | discount.activityDisAmountDesc && (discount.activityDisAmountDesc.discountAmount = util.formatFixed(discount.activityDisAmountDesc.discountAmount)); 50 | discount.rightsDisAmountDesc && (discount.rightsDisAmountDesc.levelRightsDiscountRmb = util.formatFixed(discount.rightsDisAmountDesc.levelRightsDiscountRmb)); 51 | discount.rightsDisAmountDesc && (discount.rightsDisAmountDesc.increaseRmb = util.formatFixed(discount.rightsDisAmountDesc.increaseRmb)); 52 | discount.rightsDisAmountDesc && (discount.rightsDisAmountDesc.reduceRmb = util.formatFixed(discount.rightsDisAmountDesc.reduceRmb)); 53 | if (discount) { 54 | that.setData({ 55 | discount 56 | }); 57 | } 58 | }, 59 | fail: function (res) { 60 | wx.showModal({ 61 | title: '出错了', 62 | content: res.data.error.message, 63 | showCancel: false 64 | }); 65 | }, 66 | complete: function () { 67 | wx.hideLoading(); 68 | } 69 | }); 70 | } 71 | }); 72 | }, 73 | 74 | /** 75 | * 生命周期函数--监听页面初次渲染完成 76 | */ 77 | onReady: function () { 78 | 79 | }, 80 | 81 | /** 82 | * 生命周期函数--监听页面显示 83 | */ 84 | onShow: function () { 85 | 86 | }, 87 | 88 | /** 89 | * 生命周期函数--监听页面隐藏 90 | */ 91 | onHide: function () { 92 | 93 | }, 94 | 95 | /** 96 | * 生命周期函数--监听页面卸载 97 | */ 98 | onUnload: function () { 99 | 100 | }, 101 | 102 | /** 103 | * 页面相关事件处理函数--监听用户下拉动作 104 | */ 105 | onPullDownRefresh: function () { 106 | 107 | }, 108 | 109 | /** 110 | * 页面上拉触底事件的处理函数 111 | */ 112 | onReachBottom: function () { 113 | 114 | }, 115 | 116 | /** 117 | * 用户点击右上角分享 118 | */ 119 | onShareAppMessage: function () { 120 | 121 | } 122 | }) -------------------------------------------------------------------------------- /pages/topup/topupDiscounts.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": { 3 | "List": "/components/List/List", 4 | "ListItem": "/components/List/ListItem" 5 | } 6 | } -------------------------------------------------------------------------------- /pages/topup/topupDiscounts.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 优惠金额 7 | {{discount.discountAmount}}元 8 | 9 | 10 | 优惠券优惠金额 11 | {{discount.couponDisAmountDesc.discountAmount}}元 12 | 13 | 14 | 已使用优惠券 15 | {{discount.couponDisAmountDesc.couponName}} 16 | 17 | 18 | 活动优惠金额 19 | {{discount.activityDisAmountDesc.discountAmount}}元 20 | 21 | 22 | 权益折扣优惠金额 23 | {{discount.rightsDisAmountDesc.levelRightsDiscountRmb}}元 24 | 25 | 26 | 权益充值送金额 27 | {{discount.rightsDisAmountDesc.increaseRmb}}元 28 | 29 | 30 | 权益充值送积分 31 | {{discount.rightsDisAmountDesc.fullSendBonus}}分 32 | 33 | 34 | 积分抵扣金额 35 | {{discount.rightsDisAmountDesc.reduceRmb}}元 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /pages/topup/topupDiscounts.wxss: -------------------------------------------------------------------------------- 1 | /* pages/topup/topupDiscounts.wxss */ 2 | .item_desc{ 3 | color:#B2B2B2; 4 | } -------------------------------------------------------------------------------- /pages/topup/topupResult.js: -------------------------------------------------------------------------------- 1 | // pages/topup/topupResult.js 2 | var app = getApp(); 3 | Page({ 4 | 5 | /** 6 | * 页面的初始数据 7 | */ 8 | data: { 9 | order:{} 10 | }, 11 | obj:{ 12 | timeoutNo:0 //循环次数 13 | }, 14 | 15 | /** 16 | * 生命周期函数--监听页面加载 17 | */ 18 | onLoad: function (options) { 19 | this.obj.spid = decodeURIComponent(options.spid); 20 | this.obj.orderNo = decodeURIComponent(options.orderNo); 21 | 22 | // this.obj.spid = "2000000182"; 23 | // this.obj.orderNo = "1804251000225691285"; 24 | this.loadData(); 25 | }, 26 | 27 | /** 28 | * 生命周期函数--监听页面初次渲染完成 29 | */ 30 | onReady: function () { 31 | 32 | }, 33 | 34 | /** 35 | * 生命周期函数--监听页面显示 36 | */ 37 | onShow: function () { 38 | 39 | }, 40 | 41 | /** 42 | * 生命周期函数--监听页面隐藏 43 | */ 44 | onHide: function () { 45 | 46 | }, 47 | 48 | /** 49 | * 生命周期函数--监听页面卸载 50 | */ 51 | onUnload: function () { 52 | var timer = this.obj.timer; 53 | if (timer) { 54 | clearTimeout(timer); 55 | } 56 | }, 57 | 58 | /** 59 | * 页面相关事件处理函数--监听用户下拉动作 60 | */ 61 | onPullDownRefresh: function () { 62 | 63 | }, 64 | 65 | /** 66 | * 页面上拉触底事件的处理函数 67 | */ 68 | onReachBottom: function () { 69 | 70 | }, 71 | 72 | /** 73 | * 用户点击右上角分享 74 | */ 75 | onShareAppMessage: function () { 76 | 77 | }, 78 | 79 | jumpToBack : function () { 80 | wx.navigateBack({ 81 | delta:2 82 | }); 83 | }, 84 | 85 | handleRefresh:function () { 86 | this.loadData(); 87 | }, 88 | 89 | // 跳转带优惠详情页面 90 | topupDiscounts:function(e){ 91 | wx.navigateTo({ 92 | url: '/pages/topup/topupDiscounts?listid='+this.data.order.listid+'&spid='+this.obj.spid 93 | }); 94 | }, 95 | 96 | // 领取优惠券 97 | getCoupon:function(){ 98 | var that = this; 99 | if (!this.obj.spid) { 100 | wx.showModal({ 101 | title: '出错了', 102 | content: '无法获取优惠券信息', 103 | showCancel: false 104 | }); 105 | return; 106 | } 107 | that.obj.loading = true; 108 | wx.showLoading({ 109 | title: '加载中', 110 | mask: true, 111 | success: function () { 112 | var card = that.data.receiveCoupon || []; 113 | var objList = []; 114 | for(var i=0,len=card.length;i0){ 121 | wx.addCard({ 122 | cardList: objList, 123 | success: function () { 124 | wx.showModal({ 125 | title: '优惠券', 126 | content: '领取成功', 127 | showCancel: false 128 | }); 129 | }, 130 | complete: function () { 131 | wx.hideLoading(); 132 | that.obj.loading = false; 133 | } 134 | }); 135 | } 136 | } 137 | }); 138 | }, 139 | 140 | loadData:function () { 141 | var that = this; 142 | if (!this.obj.spid || !this.obj.orderNo) { 143 | wx.showModal({ 144 | title: '出错了', 145 | content: '无法获取订单信息', 146 | showCancel: false 147 | }); 148 | return; 149 | } 150 | that.obj.loading = true; 151 | wx.showLoading({ 152 | title: '加载中', 153 | mask: true, 154 | success: function () { 155 | app.request({ 156 | url: '/user/card/recharge/result', 157 | data: { 158 | spid: that.obj.spid || '', 159 | orderNo: that.obj.orderNo 160 | }, 161 | success: function (res) { 162 | if (res.data.data){ 163 | var order = res.data.data.result; 164 | var receiveCoupon = res.data.data.receiveCoupon; 165 | order.payAmount = parseFloat(order.payAmount).toFixed(2); 166 | order.tradeAmount = parseFloat(order.tradeAmount).toFixed(2); 167 | order.balance = parseFloat(order.balance).toFixed(2); 168 | order.discountAmount = parseFloat(order.discountAmount).toFixed(2); 169 | that.setData({ 170 | order:order, 171 | receiveCoupon:receiveCoupon 172 | }); 173 | 174 | // 充值成功或者失败,不刷新数据 175 | if(order.state == 4 || order.state == 3){ 176 | }else{ 177 | that.loadResultData(); 178 | } 179 | } 180 | }, 181 | complete: function () { 182 | wx.hideLoading(); 183 | that.obj.loading = false; 184 | } 185 | }); 186 | } 187 | }); 188 | }, 189 | 190 | loadResultData:function(){ 191 | var that = this; 192 | app.request({ 193 | url: '/user/card/recharge/result', 194 | data: { 195 | spid: that.obj.spid || '', 196 | orderNo: that.obj.orderNo 197 | }, 198 | success: function (res) { 199 | if (res.data.data){ 200 | var order = res.data.data.result; 201 | var receiveCoupon = res.data.data.receiveCoupon; 202 | order.payAmount = parseFloat(order.payAmount).toFixed(2); 203 | order.tradeAmount = parseFloat(order.tradeAmount).toFixed(2); 204 | order.balance = parseFloat(order.balance).toFixed(2); 205 | order.discountAmount = parseFloat(order.discountAmount).toFixed(2); 206 | that.setData({ 207 | order:order, 208 | receiveCoupon:receiveCoupon 209 | }); 210 | } 211 | 212 | that.obj.timeoutNo = that.obj.timeoutNo + 1; 213 | // 自动刷新数据,循环10次 214 | if(order.state == 4 || order.state == 3 || that.obj.timeoutNo >= 10){ 215 | var timer = that.obj.timer; 216 | if (timer) { 217 | clearTimeout(timer); 218 | } 219 | }else{ 220 | that.obj.timer = setTimeout(function () { 221 | that.loadResultData(); 222 | }, 2000); 223 | } 224 | }, 225 | fail: function (){ 226 | var timer = that.obj.timer; 227 | if (timer) { 228 | clearTimeout(timer); 229 | } 230 | }, 231 | complete: function () { 232 | 233 | } 234 | }); 235 | } 236 | }); -------------------------------------------------------------------------------- /pages/topup/topupResult.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": { 3 | "List": "/components/List/List", 4 | "ListItem": "/components/List/ListItem" 5 | } 6 | } -------------------------------------------------------------------------------- /pages/topup/topupResult.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 充值成功 7 | 8 | 9 | 10 | 11 | 12 | 支付金额:{{order.payAmount || '0.00'}}元 13 | 到帐金额:{{order.tradeAmount || '0.00'}}元 14 | 15 | 16 | 积分奖励 17 | {{order.increaseBonus || '0.00'}} 18 | 19 | 20 | 优惠金额 21 | {{order.discountAmount || '0.00'}}元 22 | 23 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 充值失败 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 充值中,请稍等! 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /pages/topup/topupResult.wxss: -------------------------------------------------------------------------------- 1 | /* pages/topup/topupResult.wxss */ 2 | .result_top{padding-top:60rpx;text-align:center;background: #fff;} 3 | .result_top .result_top_icon .result_top_icon_img{width: 90rpx;height: 88rpx;} 4 | .result_top .result_top_msg{font-size:32rpx;margin-top:14rpx;} 5 | /* .result_bottom{margin-top:40rpx;padding:0 30rpx;}*/ 6 | .amount_transfer{color:#E94F4F;margin:0 5rpx 0 20rpx;} 7 | .amount_padin{font-size:32rpx;color:#3B4AFF;margin:0 5rpx 0 20rpx;} 8 | .amount_text{color: #000;} 9 | .get_coupon{font-size:28rpx;background: #fff;text-align: center;padding:250rpx 0 40rpx 0;} 10 | .get_coupon .get_blue_text{color: #4757FF;} 11 | .result_bottom{position:absolute;bottom:60rpx;left:0;right:0;padding:0 30rpx;} -------------------------------------------------------------------------------- /project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件。", 3 | "setting": { 4 | "urlCheck": true, 5 | "es6": false, 6 | "postcss": false, 7 | "minified": false, 8 | "newFeature": true 9 | }, 10 | "compileType": "miniprogram", 11 | "libVersion": "1.9.91", 12 | "appid": "", 13 | "projectname": "wanwan", 14 | "isGameTourist": false, 15 | "condition": { 16 | "search": { 17 | "current": -1, 18 | "list": [] 19 | }, 20 | "conversation": { 21 | "current": -1, 22 | "list": [] 23 | }, 24 | "game": { 25 | "currentL": -1, 26 | "list": [] 27 | }, 28 | "miniprogram": { 29 | "current": -1, 30 | "list": [] 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /resource/image/activity-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/activity-bg.png -------------------------------------------------------------------------------- /resource/image/advertisement-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/advertisement-bg.png -------------------------------------------------------------------------------- /resource/image/arrow_rgt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/arrow_rgt.png -------------------------------------------------------------------------------- /resource/image/arrow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/arrow_right.png -------------------------------------------------------------------------------- /resource/image/barcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/barcode.png -------------------------------------------------------------------------------- /resource/image/card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/card.png -------------------------------------------------------------------------------- /resource/image/card1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/card1.png -------------------------------------------------------------------------------- /resource/image/card2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/card2.png -------------------------------------------------------------------------------- /resource/image/card3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/card3.png -------------------------------------------------------------------------------- /resource/image/card_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/card_black.png -------------------------------------------------------------------------------- /resource/image/card_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/card_img.png -------------------------------------------------------------------------------- /resource/image/card_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/card_red.png -------------------------------------------------------------------------------- /resource/image/card_yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/card_yellow.png -------------------------------------------------------------------------------- /resource/image/check-box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/check-box.png -------------------------------------------------------------------------------- /resource/image/check_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/check_on.png -------------------------------------------------------------------------------- /resource/image/checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/checked.png -------------------------------------------------------------------------------- /resource/image/coupon_no.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/coupon_no.png -------------------------------------------------------------------------------- /resource/image/coupon_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/coupon_on.png -------------------------------------------------------------------------------- /resource/image/customer1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/customer1.png -------------------------------------------------------------------------------- /resource/image/customer2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/customer2.png -------------------------------------------------------------------------------- /resource/image/customer_logo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/customer_logo1.png -------------------------------------------------------------------------------- /resource/image/customer_logo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/customer_logo2.png -------------------------------------------------------------------------------- /resource/image/discount.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/discount.png -------------------------------------------------------------------------------- /resource/image/give.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/give.png -------------------------------------------------------------------------------- /resource/image/guide-red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/guide-red.png -------------------------------------------------------------------------------- /resource/image/member_card_banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/member_card_banner.png -------------------------------------------------------------------------------- /resource/image/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/open.png -------------------------------------------------------------------------------- /resource/image/qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/qrcode.png -------------------------------------------------------------------------------- /resource/image/recharge-success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/recharge-success.png -------------------------------------------------------------------------------- /resource/image/reduction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/reduction.png -------------------------------------------------------------------------------- /resource/image/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/refresh.png -------------------------------------------------------------------------------- /resource/image/service_ico1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/service_ico1.png -------------------------------------------------------------------------------- /resource/image/service_ico2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/service_ico2.png -------------------------------------------------------------------------------- /resource/image/service_ico3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/service_ico3.png -------------------------------------------------------------------------------- /resource/image/service_ico4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/service_ico4.png -------------------------------------------------------------------------------- /resource/image/switch-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/switch-off.png -------------------------------------------------------------------------------- /resource/image/switch-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/resource/image/switch-on.png -------------------------------------------------------------------------------- /screens/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/screens/1.jpg -------------------------------------------------------------------------------- /screens/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/screens/2.jpg -------------------------------------------------------------------------------- /screens/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/screens/3.jpg -------------------------------------------------------------------------------- /screens/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/screens/4.jpg -------------------------------------------------------------------------------- /screens/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzl307/wxClubCard/1386e22f9987e8f806148d48022f4afb677b8ee9/screens/5.jpg -------------------------------------------------------------------------------- /utils/barcode.js: -------------------------------------------------------------------------------- 1 | var CHAR_TILDE = 126; 2 | var CODE_FNC1 = 102; 3 | 4 | var SET_STARTA = 103; 5 | var SET_STARTB = 104; 6 | var SET_STARTC = 105; 7 | var SET_SHIFT = 98; 8 | var SET_CODEA = 101; 9 | var SET_CODEB = 100; 10 | var SET_STOP = 106; 11 | 12 | 13 | var REPLACE_CODES = { 14 | CHAR_TILDE: CODE_FNC1 //~ corresponds to FNC1 in GS1-128 standard 15 | } 16 | 17 | var CODESET = { 18 | ANY: 1, 19 | AB: 2, 20 | A: 3, 21 | B: 4, 22 | C: 5 23 | }; 24 | 25 | function getBytes(str) { 26 | var bytes = []; 27 | for (var i = 0; i < str.length; i++) { 28 | bytes.push(str.charCodeAt(i)); 29 | } 30 | return bytes; 31 | } 32 | 33 | exports.code128 = function (ctx, text, width, height) { 34 | 35 | width = parseInt(width); 36 | 37 | height = parseInt(height); 38 | 39 | var codes = stringToCode128(text); 40 | 41 | var g = new Graphics(ctx, width, height); 42 | 43 | var barWeight = g.area.width / ((codes.length - 3) * 11 + 35); 44 | 45 | var x = g.area.left; 46 | var y = g.area.top; 47 | for (var i = 0; i < codes.length; i++) { 48 | var c = codes[i]; 49 | //two bars at a time: 1 black and 1 white 50 | for (var bar = 0; bar < 8; bar += 2) { 51 | var barW = PATTERNS[c][bar] * barWeight; 52 | // var barH = height - y - this.border; 53 | var barH = height - y; 54 | var spcW = PATTERNS[c][bar + 1] * barWeight; 55 | 56 | //no need to draw if 0 width 57 | if (barW > 0) { 58 | g.fillFgRect(x, y, barW, barH); 59 | } 60 | 61 | x += barW + spcW; 62 | } 63 | } 64 | 65 | ctx.draw(); 66 | } 67 | 68 | 69 | function stringToCode128(text) { 70 | 71 | var barc = { 72 | currcs: CODESET.C 73 | }; 74 | 75 | var bytes = getBytes(text); 76 | //decide starting codeset 77 | var index = bytes[0] == CHAR_TILDE ? 1 : 0; 78 | 79 | var csa1 = bytes.length > 0 ? codeSetAllowedFor(bytes[index++]) : CODESET.AB; 80 | var csa2 = bytes.length > 0 ? codeSetAllowedFor(bytes[index++]) : CODESET.AB; 81 | barc.currcs = getBestStartSet(csa1, csa2); 82 | barc.currcs = perhapsCodeC(bytes, barc.currcs); 83 | 84 | //if no codeset changes this will end up with bytes.length+3 85 | //start, checksum and stop 86 | var codes = new Array(); 87 | 88 | switch (barc.currcs) { 89 | case CODESET.A: 90 | codes.push(SET_STARTA); 91 | break; 92 | case CODESET.B: 93 | codes.push(SET_STARTB); 94 | break; 95 | default: 96 | codes.push(SET_STARTC); 97 | break; 98 | } 99 | 100 | 101 | for (var i = 0; i < bytes.length; i++) { 102 | var b1 = bytes[i]; //get the first of a pair 103 | //should we translate/replace 104 | if (b1 in REPLACE_CODES) { 105 | codes.push(REPLACE_CODES[b1]); 106 | i++ //jump to next 107 | b1 = bytes[i]; 108 | } 109 | 110 | //get the next in the pair if possible 111 | var b2 = bytes.length > (i + 1) ? bytes[i + 1] : -1; 112 | 113 | codes = codes.concat(codesForChar(b1, b2, barc.currcs)); 114 | //code C takes 2 chars each time 115 | if (barc.currcs == CODESET.C) i++; 116 | } 117 | 118 | //calculate checksum according to Code 128 standards 119 | var checksum = codes[0]; 120 | for (var weight = 1; weight < codes.length; weight++) { 121 | checksum += (weight * codes[weight]); 122 | } 123 | codes.push(checksum % 103); 124 | 125 | codes.push(SET_STOP); 126 | 127 | //encoding should now be complete 128 | return codes; 129 | 130 | function getBestStartSet(csa1, csa2) { 131 | //tries to figure out the best codeset 132 | //to start with to get the most compact code 133 | var vote = 0; 134 | vote += csa1 == CODESET.A ? 1 : 0; 135 | vote += csa1 == CODESET.B ? -1 : 0; 136 | vote += csa2 == CODESET.A ? 1 : 0; 137 | vote += csa2 == CODESET.B ? -1 : 0; 138 | //tie goes to B due to my own predudices 139 | return vote > 0 ? CODESET.A : CODESET.B; 140 | } 141 | 142 | function perhapsCodeC(bytes, codeset) { 143 | for (var i = 0; i < bytes.length; i++) { 144 | var b = bytes[i] 145 | if ((b < 48 || b > 57) && b != CHAR_TILDE) 146 | return codeset; 147 | } 148 | return CODESET.C; 149 | } 150 | 151 | //chr1 is current byte 152 | //chr2 is the next byte to process. looks ahead. 153 | function codesForChar(chr1, chr2, currcs) { 154 | var result = []; 155 | var shifter = -1; 156 | 157 | if (charCompatible(chr1, currcs)) { 158 | if (currcs == CODESET.C) { 159 | if (chr2 == -1) { 160 | shifter = SET_CODEB; 161 | currcs = CODESET.B; 162 | } 163 | else if ((chr2 != -1) && !charCompatible(chr2, currcs)) { 164 | //need to check ahead as well 165 | if (charCompatible(chr2, CODESET.A)) { 166 | shifter = SET_CODEA; 167 | currcs = CODESET.A; 168 | } 169 | else { 170 | shifter = SET_CODEB; 171 | currcs = CODESET.B; 172 | } 173 | } 174 | } 175 | } 176 | else { 177 | //if there is a next char AND that next char is also not compatible 178 | if ((chr2 != -1) && !charCompatible(chr2, currcs)) { 179 | //need to switch code sets 180 | switch (currcs) { 181 | case CODESET.A: 182 | shifter = SET_CODEB; 183 | currcs = CODESET.B; 184 | break; 185 | case CODESET.B: 186 | shifter = SET_CODEA; 187 | currcs = CODESET.A; 188 | break; 189 | } 190 | } 191 | else { 192 | //no need to shift code sets, a temporary SHIFT will suffice 193 | shifter = SET_SHIFT; 194 | } 195 | } 196 | 197 | //ok some type of shift is nessecary 198 | if (shifter != -1) { 199 | result.push(shifter); 200 | result.push(codeValue(chr1)); 201 | } 202 | else { 203 | if (currcs == CODESET.C) { 204 | //include next as well 205 | result.push(codeValue(chr1, chr2)); 206 | } 207 | else { 208 | result.push(codeValue(chr1)); 209 | } 210 | } 211 | barc.currcs = currcs; 212 | 213 | return result; 214 | } 215 | } 216 | 217 | //reduce the ascii code to fit into the Code128 char table 218 | function codeValue(chr1, chr2) { 219 | if (typeof chr2 == "undefined") { 220 | return chr1 >= 32 ? chr1 - 32 : chr1 + 64; 221 | } 222 | else { 223 | return parseInt(String.fromCharCode(chr1) + String.fromCharCode(chr2)); 224 | } 225 | } 226 | 227 | function charCompatible(chr, codeset) { 228 | var csa = codeSetAllowedFor(chr); 229 | if (csa == CODESET.ANY) return true; 230 | //if we need to change from current 231 | if (csa == CODESET.AB) return true; 232 | if (csa == CODESET.A && codeset == CODESET.A) return true; 233 | if (csa == CODESET.B && codeset == CODESET.B) return true; 234 | return false; 235 | } 236 | 237 | function codeSetAllowedFor(chr) { 238 | if (chr >= 48 && chr <= 57) { 239 | //0-9 240 | return CODESET.ANY; 241 | } 242 | else if (chr >= 32 && chr <= 95) { 243 | //0-9 A-Z 244 | return CODESET.AB; 245 | } 246 | else { 247 | //if non printable 248 | return chr < 32 ? CODESET.A : CODESET.B; 249 | } 250 | } 251 | 252 | var Graphics = function (ctx, width, height) { 253 | 254 | this.width = width; 255 | this.height = height; 256 | this.quiet = Math.round(this.width / 40); 257 | 258 | this.border_size = 0; 259 | this.padding_width = 0; 260 | 261 | this.area = { 262 | width: width - this.padding_width * 2 - this.quiet * 2, 263 | height: height - this.border_size * 2, 264 | top: this.border_size - 4, 265 | left: this.padding_width + this.quiet 266 | }; 267 | 268 | this.ctx = ctx; 269 | this.fg = "#000000"; 270 | this.bg = "#ffffff"; 271 | 272 | // fill background 273 | this.fillBgRect(0, 0, width, height); 274 | 275 | // fill center to create border 276 | this.fillBgRect(0, this.border_size, width, height - this.border_size * 2); 277 | } 278 | 279 | //use native color 280 | Graphics.prototype._fillRect = function (x, y, width, height, color) { 281 | this.ctx.setFillStyle(color) 282 | this.ctx.fillRect(x, y, width, height) 283 | } 284 | 285 | Graphics.prototype.fillFgRect = function (x, y, width, height) { 286 | this._fillRect(x, y, width, height, this.fg); 287 | } 288 | 289 | Graphics.prototype.fillBgRect = function (x, y, width, height) { 290 | this._fillRect(x, y, width, height, this.bg); 291 | } 292 | 293 | var PATTERNS = [ 294 | [2, 1, 2, 2, 2, 2, 0, 0], // 0 295 | [2, 2, 2, 1, 2, 2, 0, 0], // 1 296 | [2, 2, 2, 2, 2, 1, 0, 0], // 2 297 | [1, 2, 1, 2, 2, 3, 0, 0], // 3 298 | [1, 2, 1, 3, 2, 2, 0, 0], // 4 299 | [1, 3, 1, 2, 2, 2, 0, 0], // 5 300 | [1, 2, 2, 2, 1, 3, 0, 0], // 6 301 | [1, 2, 2, 3, 1, 2, 0, 0], // 7 302 | [1, 3, 2, 2, 1, 2, 0, 0], // 8 303 | [2, 2, 1, 2, 1, 3, 0, 0], // 9 304 | [2, 2, 1, 3, 1, 2, 0, 0], // 10 305 | [2, 3, 1, 2, 1, 2, 0, 0], // 11 306 | [1, 1, 2, 2, 3, 2, 0, 0], // 12 307 | [1, 2, 2, 1, 3, 2, 0, 0], // 13 308 | [1, 2, 2, 2, 3, 1, 0, 0], // 14 309 | [1, 1, 3, 2, 2, 2, 0, 0], // 15 310 | [1, 2, 3, 1, 2, 2, 0, 0], // 16 311 | [1, 2, 3, 2, 2, 1, 0, 0], // 17 312 | [2, 2, 3, 2, 1, 1, 0, 0], // 18 313 | [2, 2, 1, 1, 3, 2, 0, 0], // 19 314 | [2, 2, 1, 2, 3, 1, 0, 0], // 20 315 | [2, 1, 3, 2, 1, 2, 0, 0], // 21 316 | [2, 2, 3, 1, 1, 2, 0, 0], // 22 317 | [3, 1, 2, 1, 3, 1, 0, 0], // 23 318 | [3, 1, 1, 2, 2, 2, 0, 0], // 24 319 | [3, 2, 1, 1, 2, 2, 0, 0], // 25 320 | [3, 2, 1, 2, 2, 1, 0, 0], // 26 321 | [3, 1, 2, 2, 1, 2, 0, 0], // 27 322 | [3, 2, 2, 1, 1, 2, 0, 0], // 28 323 | [3, 2, 2, 2, 1, 1, 0, 0], // 29 324 | [2, 1, 2, 1, 2, 3, 0, 0], // 30 325 | [2, 1, 2, 3, 2, 1, 0, 0], // 31 326 | [2, 3, 2, 1, 2, 1, 0, 0], // 32 327 | [1, 1, 1, 3, 2, 3, 0, 0], // 33 328 | [1, 3, 1, 1, 2, 3, 0, 0], // 34 329 | [1, 3, 1, 3, 2, 1, 0, 0], // 35 330 | [1, 1, 2, 3, 1, 3, 0, 0], // 36 331 | [1, 3, 2, 1, 1, 3, 0, 0], // 37 332 | [1, 3, 2, 3, 1, 1, 0, 0], // 38 333 | [2, 1, 1, 3, 1, 3, 0, 0], // 39 334 | [2, 3, 1, 1, 1, 3, 0, 0], // 40 335 | [2, 3, 1, 3, 1, 1, 0, 0], // 41 336 | [1, 1, 2, 1, 3, 3, 0, 0], // 42 337 | [1, 1, 2, 3, 3, 1, 0, 0], // 43 338 | [1, 3, 2, 1, 3, 1, 0, 0], // 44 339 | [1, 1, 3, 1, 2, 3, 0, 0], // 45 340 | [1, 1, 3, 3, 2, 1, 0, 0], // 46 341 | [1, 3, 3, 1, 2, 1, 0, 0], // 47 342 | [3, 1, 3, 1, 2, 1, 0, 0], // 48 343 | [2, 1, 1, 3, 3, 1, 0, 0], // 49 344 | [2, 3, 1, 1, 3, 1, 0, 0], // 50 345 | [2, 1, 3, 1, 1, 3, 0, 0], // 51 346 | [2, 1, 3, 3, 1, 1, 0, 0], // 52 347 | [2, 1, 3, 1, 3, 1, 0, 0], // 53 348 | [3, 1, 1, 1, 2, 3, 0, 0], // 54 349 | [3, 1, 1, 3, 2, 1, 0, 0], // 55 350 | [3, 3, 1, 1, 2, 1, 0, 0], // 56 351 | [3, 1, 2, 1, 1, 3, 0, 0], // 57 352 | [3, 1, 2, 3, 1, 1, 0, 0], // 58 353 | [3, 3, 2, 1, 1, 1, 0, 0], // 59 354 | [3, 1, 4, 1, 1, 1, 0, 0], // 60 355 | [2, 2, 1, 4, 1, 1, 0, 0], // 61 356 | [4, 3, 1, 1, 1, 1, 0, 0], // 62 357 | [1, 1, 1, 2, 2, 4, 0, 0], // 63 358 | [1, 1, 1, 4, 2, 2, 0, 0], // 64 359 | [1, 2, 1, 1, 2, 4, 0, 0], // 65 360 | [1, 2, 1, 4, 2, 1, 0, 0], // 66 361 | [1, 4, 1, 1, 2, 2, 0, 0], // 67 362 | [1, 4, 1, 2, 2, 1, 0, 0], // 68 363 | [1, 1, 2, 2, 1, 4, 0, 0], // 69 364 | [1, 1, 2, 4, 1, 2, 0, 0], // 70 365 | [1, 2, 2, 1, 1, 4, 0, 0], // 71 366 | [1, 2, 2, 4, 1, 1, 0, 0], // 72 367 | [1, 4, 2, 1, 1, 2, 0, 0], // 73 368 | [1, 4, 2, 2, 1, 1, 0, 0], // 74 369 | [2, 4, 1, 2, 1, 1, 0, 0], // 75 370 | [2, 2, 1, 1, 1, 4, 0, 0], // 76 371 | [4, 1, 3, 1, 1, 1, 0, 0], // 77 372 | [2, 4, 1, 1, 1, 2, 0, 0], // 78 373 | [1, 3, 4, 1, 1, 1, 0, 0], // 79 374 | [1, 1, 1, 2, 4, 2, 0, 0], // 80 375 | [1, 2, 1, 1, 4, 2, 0, 0], // 81 376 | [1, 2, 1, 2, 4, 1, 0, 0], // 82 377 | [1, 1, 4, 2, 1, 2, 0, 0], // 83 378 | [1, 2, 4, 1, 1, 2, 0, 0], // 84 379 | [1, 2, 4, 2, 1, 1, 0, 0], // 85 380 | [4, 1, 1, 2, 1, 2, 0, 0], // 86 381 | [4, 2, 1, 1, 1, 2, 0, 0], // 87 382 | [4, 2, 1, 2, 1, 1, 0, 0], // 88 383 | [2, 1, 2, 1, 4, 1, 0, 0], // 89 384 | [2, 1, 4, 1, 2, 1, 0, 0], // 90 385 | [4, 1, 2, 1, 2, 1, 0, 0], // 91 386 | [1, 1, 1, 1, 4, 3, 0, 0], // 92 387 | [1, 1, 1, 3, 4, 1, 0, 0], // 93 388 | [1, 3, 1, 1, 4, 1, 0, 0], // 94 389 | [1, 1, 4, 1, 1, 3, 0, 0], // 95 390 | [1, 1, 4, 3, 1, 1, 0, 0], // 96 391 | [4, 1, 1, 1, 1, 3, 0, 0], // 97 392 | [4, 1, 1, 3, 1, 1, 0, 0], // 98 393 | [1, 1, 3, 1, 4, 1, 0, 0], // 99 394 | [1, 1, 4, 1, 3, 1, 0, 0], // 100 395 | [3, 1, 1, 1, 4, 1, 0, 0], // 101 396 | [4, 1, 1, 1, 3, 1, 0, 0], // 102 397 | [2, 1, 1, 4, 1, 2, 0, 0], // 103 398 | [2, 1, 1, 2, 1, 4, 0, 0], // 104 399 | [2, 1, 1, 2, 3, 2, 0, 0], // 105 400 | [2, 3, 3, 1, 1, 1, 2, 0] // 106 401 | ] -------------------------------------------------------------------------------- /utils/code.js: -------------------------------------------------------------------------------- 1 | 2 | var barcode = require('./barcode'); 3 | 4 | var qrcode = require('./qrcode'); 5 | 6 | function convert_length(length) { 7 | return Math.round(wx.getSystemInfoSync().windowWidth * length / 750); 8 | } 9 | 10 | function barc(id, code, width, height) { 11 | barcode.code128(wx.createCanvasContext(id), code, convert_length(width), convert_length(height)) 12 | } 13 | 14 | function qrc(id, code, width, height) { 15 | qrcode.api.draw(code, { 16 | ctx: wx.createCanvasContext(id), 17 | width: convert_length(width), 18 | height: convert_length(height) 19 | }) 20 | } 21 | 22 | module.exports = { 23 | barcode: barc, 24 | qrcode: qrc 25 | }; -------------------------------------------------------------------------------- /utils/eventProxy.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 观察者模式 3 | * eventProxy 中,总共有 on、one、off、trigger 这 4 个函数: 4 | * 1、on、one:on 与 one 函数用于订阅者监听相应的事件,并将事件响应时的函数作为参数。 5 | * 2、on 与 one 的唯一区别就是,使用 one 进行订阅的函数,只会触发一次,而 使用 on 进行订阅的函数,每次事件发生相应时都会被触发。 6 | * 3、trigger:trigger 用于发布者发布事件,将除第一参数(事件名)的其他参数,作为新的参数,触发使用 one 与 on 进行订阅的函数。 7 | * 4、off:用于解除所有订阅了某个事件的所有函数。 8 | */ 9 | 'use strict'; 10 | const eventProxy = { 11 | onObj: {}, 12 | oneObj: {}, 13 | on: function(key, fn) { 14 | if(this.onObj[key] === undefined) { 15 | this.onObj[key] = []; 16 | } 17 | 18 | this.onObj[key].push(fn); 19 | }, 20 | one: function(key, fn) { 21 | if(this.oneObj[key] === undefined) { 22 | this.oneObj[key] = []; 23 | } 24 | 25 | this.oneObj[key].push(fn); 26 | }, 27 | off: function(key) { 28 | this.onObj[key] = []; 29 | this.oneObj[key] = []; 30 | }, 31 | trigger: function() { 32 | let key, args; 33 | if(arguments.length == 0) { 34 | return false; 35 | } 36 | key = arguments[0]; 37 | args = [].concat(Array.prototype.slice.call(arguments, 1)); 38 | 39 | if(this.onObj[key] !== undefined 40 | && this.onObj[key].length > 0) { 41 | for(let i in this.onObj[key]) { 42 | this.onObj[key][i].apply(null, args); 43 | } 44 | } 45 | if(this.oneObj[key] !== undefined 46 | && this.oneObj[key].length > 0) { 47 | for(let i in this.oneObj[key]) { 48 | this.oneObj[key][i].apply(null, args); 49 | this.oneObj[key][i] = undefined; 50 | } 51 | this.oneObj[key] = []; 52 | } 53 | } 54 | }; 55 | 56 | module.exports={ 57 | eventProxy:eventProxy 58 | } -------------------------------------------------------------------------------- /utils/util.js: -------------------------------------------------------------------------------- 1 | function formatTime(date) { 2 | var year = date.getFullYear(); 3 | var month = date.getMonth() + 1; 4 | var day = date.getDate(); 5 | 6 | var hour = date.getHours(); 7 | var minute = date.getMinutes(); 8 | var second = date.getSeconds(); 9 | 10 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':'); 11 | } 12 | 13 | function formatYMD(date) { 14 | var year = date.getFullYear(); 15 | var month = date.getMonth() + 1; 16 | var day = date.getDate(); 17 | 18 | var hour = date.getHours(); 19 | var minute = date.getMinutes(); 20 | var second = date.getSeconds(); 21 | 22 | return [year, month, day].map(formatNumber).join('/'); 23 | } 24 | 25 | function formatNumber(n) { 26 | n = n.toString(); 27 | return n[1] ? n : '0' + n; 28 | } 29 | 30 | // 默认固定两位小数 31 | function formatFixed(val, fixed=2){ 32 | return parseFloat(val).toFixed(fixed) 33 | } 34 | 35 | module.exports = { 36 | formatTime: formatTime, 37 | formatYMD: formatYMD, 38 | formatFixed: formatFixed, 39 | }; 40 | --------------------------------------------------------------------------------