Commit 18b982a887c77adfd490d66af2ea44e4e99ccc3e
1 parent
845dd3e8
1. store_name报警
2. 我的礼包(旧)的购买流程和核销
Showing
8 changed files
with
252 additions
and
50 deletions
app.js
| ... | ... | @@ -165,8 +165,9 @@ App({ |
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | }) |
| 168 | - | |
| 169 | - | |
| 168 | + | |
| 169 | + //获取一下门店的基本信息 | |
| 170 | + this.getConfig(); | |
| 170 | 171 | }, |
| 171 | 172 | |
| 172 | 173 | //---初始化第三方---- |
| ... | ... | @@ -216,7 +217,7 @@ App({ |
| 216 | 217 | return false; |
| 217 | 218 | } |
| 218 | 219 | if(this.globalData.config==undefined) this.globalData.config=null; |
| 219 | - this.globalData.config ? "function" == typeof t && t(this.globalData.config) : e.request.get("/api/weshop/store/get/" + e.globalData.setting.stoid, { | |
| 220 | + this.globalData.config ? "function" == typeof t && t(this.globalData.config) : e.requestGet("/api/weshop/store/get/" + e.globalData.setting.stoid, { | |
| 220 | 221 | success: function(o) { |
| 221 | 222 | console.log('getConfig'); |
| 222 | 223 | if(o.data.code==0){ |
| ... | ... | @@ -677,6 +678,27 @@ App({ |
| 677 | 678 | }) |
| 678 | 679 | }) |
| 679 | 680 | }, |
| 681 | + | |
| 682 | + | |
| 683 | + //---promise的使用get---- | |
| 684 | + requestGet:function(url,data){ | |
| 685 | + if(url.indexOf("http")==-1) url=this.globalData.setting.url +url; | |
| 686 | + data.isShowLoading && wx.showLoading(); | |
| 687 | + wx.request({ | |
| 688 | + url, | |
| 689 | + method: 'GET', | |
| 690 | + header: {"content-type": "application/x-www-form-urlencoded" }, | |
| 691 | + data:data.data, | |
| 692 | + success(res) { | |
| 693 | + data.isShowLoading && wx.hideLoading(); | |
| 694 | + data.success(res); | |
| 695 | + }, | |
| 696 | + fail(err) { | |
| 697 | + data.isShowLoading && wx.hideLoading(); | |
| 698 | + if(data.fail) data.fail(err); | |
| 699 | + } | |
| 700 | + }) | |
| 701 | + }, | |
| 680 | 702 | |
| 681 | 703 | |
| 682 | 704 | // 判断是否登录 | ... | ... |
components/qr_code/qr_code.wxss
| ... | ... | @@ -57,10 +57,11 @@ left: 0rpx; |
| 57 | 57 | .barcode { |
| 58 | 58 | height:150rpx; |
| 59 | 59 | width: 620rpx; |
| 60 | - | |
| 61 | 60 | text-align:center; |
| 62 | 61 | position:absolute; |
| 63 | - left: 30rpx | |
| 62 | + left: 30rpx; | |
| 63 | + top: -6rpx; | |
| 64 | + | |
| 64 | 65 | } |
| 65 | 66 | canvas{ |
| 66 | 67 | width:100%; |
| ... | ... | @@ -83,6 +84,7 @@ display:flex; |
| 83 | 84 | flex-direction:column; |
| 84 | 85 | position: absolute; |
| 85 | 86 | left: 75rpx; |
| 87 | +top: 5rpx; | |
| 86 | 88 | |
| 87 | 89 | } |
| 88 | 90 | .qrcode{ | ... | ... |
packageA/pages/hongBao/hongBao.js
| ... | ... | @@ -34,9 +34,15 @@ Page({ |
| 34 | 34 | .then(function(data) { |
| 35 | 35 | self.data.hongBaoData = data.data.data; |
| 36 | 36 | self.countDown(); |
| 37 | - self.setData({ | |
| 38 | - storeName: app.globalData.config.store_name | |
| 39 | - }); | |
| 37 | + setTimeout(function (){ | |
| 38 | + if(app.globalData.config && app.globalData.config.store_name){ | |
| 39 | + self.setData({ | |
| 40 | + storeName: app.globalData.config.store_name | |
| 41 | + }); | |
| 42 | + } | |
| 43 | + | |
| 44 | + },1000) | |
| 45 | + | |
| 40 | 46 | }); |
| 41 | 47 | |
| 42 | 48 | }); | ... | ... |
packageA/pages/myGift/myGift.js
| ... | ... | @@ -47,6 +47,9 @@ Page({ |
| 47 | 47 | */ |
| 48 | 48 | onLoad: function (options) { |
| 49 | 49 | self = this; |
| 50 | + if(options.index){ | |
| 51 | + this.setData({currentIndex:1}); //查看我的礼包 | |
| 52 | + } | |
| 50 | 53 | app.isLogin().then(function(data) {//进入页面前已经授权登录成功 |
| 51 | 54 | self.setData({ |
| 52 | 55 | userInfo: data, |
| ... | ... | @@ -57,9 +60,7 @@ Page({ |
| 57 | 60 | /** |
| 58 | 61 | * 生命周期函数--监听页面初次渲染完成 |
| 59 | 62 | */ |
| 60 | - onReady: function () { | |
| 61 | - | |
| 62 | - }, | |
| 63 | + onReady: function () {}, | |
| 63 | 64 | |
| 64 | 65 | /** |
| 65 | 66 | * 生命周期函数--监听页面显示 |
| ... | ... | @@ -72,11 +73,26 @@ Page({ |
| 72 | 73 | imghost: app.globalData.setting.imghost, |
| 73 | 74 | isLogin: true, |
| 74 | 75 | }); |
| 75 | - | |
| 76 | - this.getData(true, '/api/weshop/libao/libaoForm/page', { | |
| 76 | + | |
| 77 | + var index=this.data.currentIndex; | |
| 78 | + let url = ''; | |
| 79 | + let data = { | |
| 77 | 80 | store_id: app.globalData.setting.stoid, |
| 78 | 81 | user_id: app.globalData.user_id, |
| 79 | - }); | |
| 82 | + }; | |
| 83 | + this.setData({ | |
| 84 | + list: null, | |
| 85 | + pageNum: 1, | |
| 86 | + noMore: false, | |
| 87 | + }); | |
| 88 | + | |
| 89 | + if(index == 0) { | |
| 90 | + url = '/api/weshop/libao/libaoForm/page'; | |
| 91 | + } else if(index == 1) { | |
| 92 | + url = '/api/weshop/libao/libaoFormvip/page'; | |
| 93 | + }; | |
| 94 | + | |
| 95 | + this.getData(true, url, data); | |
| 80 | 96 | }; |
| 81 | 97 | }; |
| 82 | 98 | }, | ... | ... |
packageA/pages/myGiftDetails/myGiftDetails.js
| 1 | 1 | // packageA//pages/myGiftDetails/myGiftDetails.js |
| 2 | 2 | const app = getApp(); |
| 3 | 3 | let self = null; |
| 4 | +var os = app.globalData.setting; | |
| 4 | 5 | |
| 5 | 6 | Page({ |
| 6 | 7 | |
| ... | ... | @@ -8,7 +9,10 @@ Page({ |
| 8 | 9 | * 页面的初始数据 |
| 9 | 10 | */ |
| 10 | 11 | data: { |
| 11 | - | |
| 12 | + qr_code_object: { | |
| 13 | + val: "12121", | |
| 14 | + content: "请将二维码展示给核销员,服务更快捷!" | |
| 15 | + }, | |
| 12 | 16 | }, |
| 13 | 17 | |
| 14 | 18 | /** |
| ... | ... | @@ -90,9 +94,11 @@ Page({ |
| 90 | 94 | isShowLoading: true, |
| 91 | 95 | }).then(function(res) { |
| 92 | 96 | // console.log('res3-->', res); |
| 93 | - self.setData({ | |
| 94 | - details: res.data.data.pageData[0], | |
| 95 | - }); | |
| 97 | + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){ | |
| 98 | + self.setData({ | |
| 99 | + details: res.data.data.pageData[0], | |
| 100 | + }); | |
| 101 | + } | |
| 96 | 102 | }); |
| 97 | 103 | |
| 98 | 104 | app.request.promiseGet('/api/weshop/libao/libaoListvip/page', { |
| ... | ... | @@ -103,9 +109,15 @@ Page({ |
| 103 | 109 | isShowLoading: true, |
| 104 | 110 | }).then(function(res) { |
| 105 | 111 | // console.log('res4-->', res); |
| 106 | - self.setData({ | |
| 107 | - list: res.data.data.pageData, | |
| 108 | - }); | |
| 112 | + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0) { | |
| 113 | + var list_arr=res.data.data.pageData; | |
| 114 | + for(var i in list_arr){ | |
| 115 | + list_arr[i].alsonum= list_arr[i]['goods_num'] - list_arr[i]['usenum'];//剩余次数 | |
| 116 | + } | |
| 117 | + self.setData({ | |
| 118 | + list: res.data.data.pageData, | |
| 119 | + }); | |
| 120 | + } | |
| 109 | 121 | }); |
| 110 | 122 | }; |
| 111 | 123 | |
| ... | ... | @@ -114,38 +126,148 @@ Page({ |
| 114 | 126 | }; |
| 115 | 127 | }, |
| 116 | 128 | |
| 117 | - /** | |
| 118 | - * 生命周期函数--监听页面隐藏 | |
| 129 | + /** | |
| 130 | + * 用户点击右上角分享 | |
| 119 | 131 | */ |
| 120 | - onHide: function () { | |
| 132 | + onShareAppMessage: function () { | |
| 121 | 133 | |
| 122 | 134 | }, |
| 123 | 135 | |
| 124 | - /** | |
| 125 | - * 生命周期函数--监听页面卸载 | |
| 126 | - */ | |
| 127 | - onUnload: function () { | |
| 136 | + //-- 礼包购买 -- | |
| 137 | + GetBuyPrice: function(e) { | |
| 138 | + var th = this,that=th; | |
| 139 | + var item=th.data.details; | |
| 140 | + var id = item.id; //活动id | |
| 141 | + var my_confirm = th.selectComponent("#my_confirm"); //组件的id | |
| 142 | + var user=getApp().globalData.userInfo; | |
| 128 | 143 | |
| 129 | - }, | |
| 144 | + my_confirm.open( | |
| 145 | + "是否确定购买该礼包", | |
| 146 | + "取消", | |
| 147 | + "确定", | |
| 148 | + function() { | |
| 149 | + my_confirm.open_cancel(0); | |
| 150 | + }, | |
| 151 | + function() { | |
| 152 | + my_confirm.open_cancel(0); | |
| 153 | + var json = { | |
| 154 | + "lbid": id, //活动Id | |
| 155 | + "paytype": 2, //1=积分兑换 2=购买 | |
| 156 | + "store_id": os.stoid, //商家Id | |
| 157 | + "user_id": user.user_id, //用户ID | |
| 158 | + }; | |
| 159 | + var url = "/api/weshop/libao/libaoFormvip/libaoOrder"; | |
| 160 | + getApp().request.post(url, | |
| 161 | + { | |
| 162 | + data:json, | |
| 163 | + success:function(res) { | |
| 164 | + if (res.data.code == 0 && res.data.data) { | |
| 165 | + res = res.data.data; | |
| 166 | + wx.requestPayment({ | |
| 167 | + timeStamp: String(res.timeStamp), | |
| 168 | + nonceStr: res.nonceStr, | |
| 169 | + package: res.packageValue, | |
| 170 | + signType: res.signType, | |
| 171 | + paySign: res.paySign, | |
| 172 | + success: function(res) { | |
| 173 | + getApp().my_warnning("支付成功", 1, th); | |
| 174 | + setTimeout(function (){ | |
| 175 | + getApp().goto("/packageA/pages/libao_payment/payment?type=2"); | |
| 176 | + },1000) | |
| 177 | + }, | |
| 178 | + fail: function(res) { | |
| 179 | + getApp().my_warnning("取消支付", 0, th); | |
| 180 | + } | |
| 181 | + }); | |
| 182 | + } else { | |
| 183 | + getApp().my_warnning(res.data.msg, 0, th); | |
| 184 | + } | |
| 185 | + } | |
| 186 | + }) | |
| 187 | + }) | |
| 188 | + }, | |
| 130 | 189 | |
| 131 | - /** | |
| 132 | - * 页面相关事件处理函数--监听用户下拉动作 | |
| 133 | - */ | |
| 134 | - onPullDownRefresh: function () { | |
| 190 | + //-- 积分兑换 -- | |
| 191 | + GetBuyIntegral: function(e) { | |
| 192 | + var th = this,that=th; | |
| 193 | + var item=th.data.details; | |
| 135 | 194 | |
| 136 | - }, | |
| 195 | + var id = item.id; //活动id | |
| 196 | + var my_confirm = th.selectComponent("#my_confirm"); //组件的id | |
| 197 | + var user=getApp().globalData.userInfo; | |
| 198 | + my_confirm.open( | |
| 199 | + "是否确定兑换该礼包", | |
| 200 | + "取消", | |
| 201 | + "确定", | |
| 202 | + function() { | |
| 203 | + my_confirm.open_cancel(0); | |
| 204 | + }, | |
| 205 | + function() { | |
| 206 | + my_confirm.open_cancel(0); | |
| 207 | + var json = { | |
| 208 | + "lbid": id, //活动Id | |
| 209 | + "paytype": 1, //1=积分兑换 2=购买 | |
| 210 | + "store_id": os.stoid, //商家Id | |
| 211 | + "user_id": user.user_id, //用户ID | |
| 212 | + }; | |
| 213 | + var url = "/api/weshop/libao/libaoFormvip/libaoOrder"; | |
| 214 | + getApp().request.post(url,{ | |
| 215 | + data:json, | |
| 216 | + success:function(res) { | |
| 217 | + if (res.data.code == 0) { | |
| 218 | + getApp().my_warnning("兑换成功!", 1, th); | |
| 219 | + setTimeout(function (){ | |
| 220 | + getApp().goto("/packageA/pages/libao_payment/payment?type=1"); | |
| 221 | + },1000) | |
| 222 | + } else { | |
| 223 | + getApp().my_warnning(res.data.msg, 0, th); | |
| 224 | + } | |
| 225 | + }, | |
| 226 | + }) | |
| 137 | 227 | |
| 138 | - /** | |
| 139 | - * 页面上拉触底事件的处理函数 | |
| 140 | - */ | |
| 141 | - onReachBottom: function () { | |
| 228 | + }) | |
| 229 | + }, | |
| 142 | 230 | |
| 143 | - }, | |
| 231 | + //显示二维码,进行核销 | |
| 232 | + show_hxm:function (e){ | |
| 233 | + var th=this; | |
| 234 | + var type=e.currentTarget.dataset.type; | |
| 235 | + var data={}; | |
| 236 | + data.store_id=os.stoid; | |
| 237 | + data.user_id=getApp().globalData.user_id; | |
| 238 | + | |
| 239 | + if(type && parseInt(type)==1){ | |
| 240 | + data.id=this.data.id; | |
| 241 | + data.type=1; | |
| 242 | + }else{ | |
| 243 | + var index=e.currentTarget.dataset.index; | |
| 244 | + var item=this.data.list[index]; | |
| 245 | + data.id=item.id; | |
| 246 | + data.type=2; | |
| 247 | + } | |
| 248 | + | |
| 249 | + //获取二维码 | |
| 250 | + getApp().request.get("/api/weshop/libao/libaoListvip/getLibaoCode",{ | |
| 251 | + data:data, | |
| 252 | + success:function (res){ | |
| 253 | + if(res.data.code==0){ | |
| 254 | + th.data.qr_code_object.val=res.data.data; | |
| 255 | + var qc_com = th.selectComponent("#qrcode"); //组件的id | |
| 256 | + qc_com.open(th.data.qr_code_object) | |
| 257 | + }else{ | |
| 258 | + wx.showToast({ | |
| 259 | + title: res.data.msg, | |
| 260 | + icon: 'none', | |
| 261 | + duration: 2000 | |
| 262 | + }) | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + } | |
| 267 | + } | |
| 268 | + }) | |
| 269 | + | |
| 270 | + } | |
| 144 | 271 | |
| 145 | - /** | |
| 146 | - * 用户点击右上角分享 | |
| 147 | - */ | |
| 148 | - onShareAppMessage: function () { | |
| 149 | 272 | |
| 150 | - } | |
| 151 | 273 | }) |
| 152 | 274 | \ No newline at end of file | ... | ... |
packageA/pages/myGiftDetails/myGiftDetails.json
| ... | ... | @@ -3,6 +3,8 @@ |
| 3 | 3 | "enablePullDownRefresh": false, |
| 4 | 4 | "usingComponents": { |
| 5 | 5 | "warn": "/components/long_warn/long_warn", |
| 6 | - "nav_b": "/components/nav_b/nav_b" | |
| 6 | + "nav_b": "/components/nav_b/nav_b", | |
| 7 | + "my_confirm": "/components/my_confirm/my_confirm", | |
| 8 | + "qrcode":"/components/qr_code/qr_code" | |
| 7 | 9 | } |
| 8 | 10 | } |
| 9 | 11 | \ No newline at end of file | ... | ... |
packageA/pages/myGiftDetails/myGiftDetails.wxml
| ... | ... | @@ -20,7 +20,28 @@ |
| 20 | 20 | <!-- 单品 --> |
| 21 | 21 | <view class="goods-container"> |
| 22 | 22 | <view class="pd20 bold bdb">可到线下门店兑换以下单品</view> |
| 23 | - <view class=""> | |
| 23 | + <view wx:if="{{index==1 && details.codetype==1}}" class=""> | |
| 24 | + <view class="flex pd20 jc_sb"> | |
| 25 | + <view style="width: 35%">单品名称</view> | |
| 26 | + <view style="width: 25%;text-align: center">总数量</view> | |
| 27 | + <view style="width: 25%;text-align: center">剩余数量</view> | |
| 28 | + <view style="width: 15%;"></view> | |
| 29 | + </view> | |
| 30 | + <view class="flex pd20 jc_sb" wx:for="{{list}}"> | |
| 31 | + <view style="width: 35%">{{item.goods_name}}</view> | |
| 32 | + <view style="width: 25%;text-align:center" class="c-a4">x{{item.goods_num}}</view> | |
| 33 | + <view style="width: 25%;text-align:center" class="c-a4">x{{item.alsonum}}</view> | |
| 34 | + <view bindtap="show_hxm" data-index="{{index}}" style="width: 15%;text-align: center" wx:if="{{item.alsonum>0}}" > | |
| 35 | + <text class="ling_btn">使用</text> | |
| 36 | + </view> | |
| 37 | + <view style="width: 15%;text-align: center" wx:else > | |
| 38 | + <text class="ling_btn c_a">已领</text> | |
| 39 | + </view> | |
| 40 | + </view> | |
| 41 | + </view> | |
| 42 | + | |
| 43 | + | |
| 44 | + <view wx:else class=""> | |
| 24 | 45 | <view class="flex pd20 jc_sb"> |
| 25 | 46 | <view>单品名称</view> |
| 26 | 47 | <view>数量</view> |
| ... | ... | @@ -35,9 +56,15 @@ |
| 35 | 56 | <!-- 按钮 --> |
| 36 | 57 | <view class="btn-container"> |
| 37 | 58 | <block wx:if="{{index == 0}}"> |
| 38 | - <view class="btn red">立即兑换</view> | |
| 39 | - <view class="btn pink">立即购买</view> | |
| 59 | + <view bindtap="GetBuyIntegral" class="btn red">立即兑换</view> | |
| 60 | + <view bindtap="GetBuyPrice" class="btn pink">立即购买</view> | |
| 40 | 61 | </block> |
| 41 | - <view wx:else class="btn red">立即使用</view> | |
| 62 | + <view wx:else bindtap="show_hxm" data-type="1" class="btn red">立即使用</view> | |
| 42 | 63 | </view> |
| 43 | 64 | </view> |
| 65 | + | |
| 66 | +<!-- 引入提示组件 --> | |
| 67 | +<warn id="warn"></warn> | |
| 68 | +<my_confirm id="my_confirm"></my_confirm> | |
| 69 | +<qrcode id="qrcode" ></qrcode> | |
| 70 | + | ... | ... |
packageA/pages/myGiftDetails/myGiftDetails.wxss
| ... | ... | @@ -76,4 +76,9 @@ page { |
| 76 | 76 | .btn.pink { |
| 77 | 77 | background-color: #FACAD6; |
| 78 | 78 | color: #FF6768; |
| 79 | -} | |
| 80 | 79 | \ No newline at end of file |
| 80 | +} | |
| 81 | + | |
| 82 | +.ling_btn{ background: #c0283a; color: #fff; width: 100rpx; height: 50rpx; | |
| 83 | + display: inline-block; line-height: 50rpx; border-radius: 10rpx} | |
| 84 | + | |
| 85 | +.ling_btn.c_a{ background: darkgrey} | |
| 81 | 86 | \ No newline at end of file | ... | ... |