Commit f6452c96de64843827e21ff8238a534e402e8065

Authored by yvan.ni
1 parent 0e424c64

预存的功能的优化

components/qr_code/qr_code.wxml
... ... @@ -11,14 +11,15 @@
11 11 <view class="q_code">{{object.val}}</view>
12 12 </view>
13 13 <view class="qrcode_rim {{is_fw==0?'mt':'mts'}}">
14   - <canvas class="qrcode" canvas-id="qrcode{{item.index}}" wx:for="{{barcode_canvas}}" />
15   - <view class="r-code">{{object.content}}</view>
  14 + <canvas class="qrcode" canvas-id="qrcode{{item.index}}" wx:for="{{barcode_canvas}}" />
  15 + <view class="r-code">{{object.content}}</view>
16 16 <view class="r-code flex" wx:if="{{object.is_quan}}">有效时间:{{object.now}} 至 <view>{{object.validay}}</view></view>
17 17 <block wx:if="{{object.is_quan}}">
18 18 <view class="r-code" wx:if="{{object.name}}">使用说明: 仅{{object.name}}使用</view>
19 19 <view class="r-code" wx:else>使用说明: 全场通用</view>
20 20 </block>
21   - <view></view>
  21 + <view wx:if="{{object.code}}" class="code_show">{{object.code}}</view>
  22 + <view></view>
22 23 </view>
23 24 </view>
24 25  
... ...
components/qr_code/qr_code.wxss
... ... @@ -78,11 +78,11 @@ letter-spacing:6rpx;
78 78 /* 二维码边框*/
79 79 .qrcode_rim {
80 80 width: 550rpx;
81   - height:544rpx;
  81 + height:544rpx;
82 82 display:flex;
83 83 flex-direction:column;
84 84 position: absolute;
85   -left: 74rpx;
  85 +left: 75rpx;
86 86  
87 87 }
88 88 .qrcode{
... ... @@ -125,4 +125,8 @@ margin-top: -5.5rpx;
125 125 .flex{
126 126 display: flex;
127 127 justify-content:center;
  128 +}
  129 +
  130 +.code_show{
  131 + text-align: center;position: relative; left: -20rpx;
128 132 }
129 133 \ No newline at end of file
... ...
packageA/pages/chongzhi/chongzhi.js
1 1 // packageA//pages/chongzhi/chongzhi.js
2 2 const app = getApp();
3   -
4   -// var e = function(e) {
5   -// return e && e.__esModule ? e : {
6   -// default: e
7   -// };
8   -// }(require("../../../utils/LoadMore.js"));
9   -
  3 +var util = require('../../../utils/util.js');
10 4  
11 5 Page({
12 6  
... ... @@ -34,8 +28,9 @@ Page({
34 28 */
35 29 onLoad: function (options) {
36 30  
37   - console.log('userInfo',app.globalData.userInfo);
  31 +
38 32 var self = this;
  33 +
39 34 this.getData(true,'/api/weshop/users/pageNewVIPAddMoney',{
40 35 store_id: app.globalData.userInfo.store_id,
41 36 user_id: app.globalData.userInfo.user_id,
... ... @@ -57,13 +52,7 @@ Page({
57 52 });
58 53 },
59 54  
60   - /**
61   - * 生命周期函数--监听页面初次渲染完成
62   - */
63   - onReady: function () {
64   -
65   - },
66   -
  55 +
67 56 /**
68 57 * 生命周期函数--监听页面显示
69 58 */
... ... @@ -72,20 +61,6 @@ Page({
72 61 },
73 62  
74 63 /**
75   - * 生命周期函数--监听页面隐藏
76   - */
77   - onHide: function () {
78   -
79   - },
80   -
81   - /**
82   - * 生命周期函数--监听页面卸载
83   - */
84   - onUnload: function () {
85   -
86   - },
87   -
88   - /**
89 64 * 页面相关事件处理函数--监听用户下拉动作
90 65 */
91 66 onPullDownRefresh: function () {
... ... @@ -150,8 +125,7 @@ Page({
150 125 this.setData({
151 126 saveData: data
152 127 });
153   - }
154   -
  128 + }
155 129 this.getData(true,'/api/weshop/users/pageNewVIPAddMoney',data);
156 130 },
157 131  
... ... @@ -197,12 +171,21 @@ Page({
197 171 },
198 172  
199 173  
200   - viewDetails(e) {
201   - let id = e.target.dataset.id;
202   - // console.log('eeeeeeeeeee', id);
203   - app.goto('../chongzhiDetails/chongzhiDetails?id=' + id);
  174 + goDetails(e) {
  175 + let id = e.currentTarget.dataset.id;
  176 + app.goto('../chongzhiDetails/chongzhiDetails?id=' + id+"&type=1");
204 177 },
205 178  
  179 + viewDetails(e){
  180 + var index=e.currentTarget.dataset.index;
  181 + var WriteOffCode=this.data.list[index].WriteOffCode;
  182 +
  183 + var qrcode = this.selectComponent("#qrcode"); //组件的id
  184 + var code=util.base64_encode(WriteOffCode + '|' + util.formatTime());
  185 + var e={is_fw:1,val:code,code:WriteOffCode}
  186 + qrcode.open(e);
  187 +
  188 + },
206 189  
207 190 // 检测上拉滚动到底部
208 191 // scrollToLower: function (requestData, callback) {
... ... @@ -228,4 +211,12 @@ Page({
228 211 // this.getData(false, requestData, callback);
229 212 // };
230 213 // },
  214 +
  215 +
  216 + bind_err:function(e){
  217 + var _errImg = e.target.dataset.errorimg;
  218 + var _errObj = {};
  219 + _errObj[_errImg] = "/miniapp/images/default_g_img.gif";
  220 + this.setData(_errObj);
  221 + }
231 222 })
232 223 \ No newline at end of file
... ...
packageA/pages/chongzhi/chongzhi.json
... ... @@ -2,6 +2,7 @@
2 2 "navigationBarTitleText": "充值有礼",
3 3 "enablePullDownRefresh": false,
4 4 "usingComponents": {
5   - "nodata": "/components/nodata/nodata"
  5 + "nodata": "/components/nodata/nodata",
  6 + "qrcode":"/components/qr_code/qr_code"
6 7 }
7 8 }
8 9 \ No newline at end of file
... ...
packageA/pages/chongzhi/chongzhi.wxml
... ... @@ -10,9 +10,8 @@
10 10 </view>
11 11 <!-- 内容 -->
12 12 <view class="list">
13   -
14   -
15   - <view class="l-item" wx:for="{{list}}">
  13 + <block wx:for="{{list}}" >
  14 + <view class="l-item" bindtap="goDetails" data-id="{{item.ID}}" >
16 15 <!-- 上 -->
17 16 <view class="{{currentIndex == 0 ? 'top flex':'flex'}}">
18 17 <!-- 左 -->
... ... @@ -29,18 +28,17 @@
29 28 </view>
30 29 </view>
31 30 <!-- 下 -->
32   - <view class="bottom" wx:if="{{currentIndex == 0}}" bindtap="viewDetails">
33   - <text class="btn" data-id="{{item.ID}}">立即使用</text>
  31 + <view class="bottom" wx:if="{{currentIndex == 0}}" catchtap="viewDetails" data-index="{{index}}" >
  32 + <text class="btn" >立即使用</text>
34 33 </view>
35   - </view>
36   -
37   -
38   -
39   -
40   - <nodata nodataContainer="nodata" wx:if="{{list.length === 0}}">暂无数据</nodata>
41   - <view hidden="{{!noMore}}" class="no-more t-c" wx:if="{{list.length !== 0}}">- 已全部加载 -</view>
42   -
43   -
  34 + </view>
  35 + </block>
  36 +
  37 + <nodata nodataContainer="nodata" wx:if="{{list.length === 0}}">暂无数据</nodata>
  38 + <view hidden="{{!noMore}}" class="no-more t-c" wx:if="{{list.length !== 0}}">- 已全部加载 -</view>
  39 +
44 40 </view>
45 41 </view>
46   -</view>
47 42 \ No newline at end of file
  43 +</view>
  44 +
  45 +<qrcode id="qrcode" ></qrcode>
48 46 \ No newline at end of file
... ...
packageA/pages/chongzhiDetails/chongzhiDetails.js
1 1 // packageA//pages/chongzhiDetails/chongzhiDetails.js
2 2 var util = require('../../../utils/util.js');
3   -
4   -const app = getApp();
5   -
  3 +const app = getApp(),os = app.globalData.setting;
  4 +
6 5 Page({
7 6  
8 7 /**
... ... @@ -11,39 +10,57 @@ Page({
11 10 data: {
12 11 showCode: false,
13 12 result: null,
  13 + show_img:null,
  14 + url: app.globalData.setting.imghost,
  15 + type:0, //0是立即充值 1是购买后的
14 16 },
15 17  
16 18 /**
17 19 * 生命周期函数--监听页面加载
18 20 */
19 21 onLoad: function (options) {
20   - const self = this;
21   - app.request.get('/api/weshop/users/getBuyaddmoneyactDetails', {
  22 +
  23 + const self = this;
  24 + if(options.type)
  25 + self.setData({type:options.type});
  26 +
  27 + var UserInfo=app.globalData.userInfo;
  28 + if(!UserInfo) {
  29 + getApp().goto("/pages/togoin/togoin");
  30 + return false;
  31 + }
  32 +
  33 + getApp().request.promiseGet("/api/weshop/ad/list",{
  34 + data:{store_id:os.stoid,enabled:1,pid:601}
  35 + }).then(res=>{
  36 + if(res.data.code==0){
  37 + self.setData({show_img:res.data.data[0].ad_code});
  38 + }
  39 + })
  40 +
  41 + var api="/api/weshop/users/getAddmoneyactDetails";
  42 + if(options.type==1){
  43 + api="/api/weshop/users/getBuyaddmoneyactDetails";
  44 + }
  45 +
  46 + app.request.get(api, {
22 47 data: {
23 48 Id:options.id,
24   - store_id:1,
25   - user_id:6519826,
  49 + store_id:os.stoid,
  50 + user_id: UserInfo.user_id ,
26 51 },
27 52 success: function (res) {
28 53 self.setData({
29 54 result: res.data.data
30 55 });
31   -
32   - console.log('33333333--->', );
  56 +
33 57 },
34 58 });
35   -
36   -
  59 +
37 60 // this.data.result.WriteOffCode
38 61 },
39 62  
40   - /**
41   - * 生命周期函数--监听页面初次渲染完成
42   - */
43   - onReady: function () {
44   -
45   - },
46   -
  63 +
47 64 /**
48 65 * 生命周期函数--监听页面显示
49 66 */
... ... @@ -52,20 +69,6 @@ Page({
52 69 },
53 70  
54 71 /**
55   - * 生命周期函数--监听页面隐藏
56   - */
57   - onHide: function () {
58   -
59   - },
60   -
61   - /**
62   - * 生命周期函数--监听页面卸载
63   - */
64   - onUnload: function () {
65   -
66   - },
67   -
68   - /**
69 72 * 页面相关事件处理函数--监听用户下拉动作
70 73 */
71 74 onPullDownRefresh: function () {
... ... @@ -86,20 +89,100 @@ Page({
86 89  
87 90 },
88 91  
89   - onUse() {
90   -
91   -
92   - if(this.data.showCode) {
93   - this.setData({
94   - showCode: false
95   - });
96   - } else {
97   - this.setData({
98   - showCode: true
99   - });
100   -
101   - var qrcode = this.selectComponent("#qrcode"); //组件的id
102   - qrcode.open(util.base64_encode(this.data.result.WriteOffCode + '|' + util.formatTime()));
103   - };
104   - }
  92 + onUse() {
  93 + var qrcode = this.selectComponent("#qrcode"); //组件的id
  94 + var code=util.base64_encode(this.data.result.WriteOffCode + '|' + util.formatTime());
  95 + var e={is_fw:1,val:code,code:this.data.result.WriteOffCode}
  96 + qrcode.open(e);
  97 + },
  98 +
  99 +
  100 + bind_err:function(e){
  101 + var _errImg = e.target.dataset.errorimg;
  102 + var _errObj = {};
  103 + _errObj[_errImg] = "/miniapp/images/default_g_img.gif";
  104 + this.setData(_errObj);
  105 + },
  106 +
  107 + //-- 确定充值 --
  108 + go_buy: function(e) {
  109 +
  110 + var money = e.target.dataset.money;
  111 + var advance = e.target.dataset.advance;
  112 + this.recharge(money, advance);
  113 + },
  114 + //确定接口
  115 + async recharge(money, advancek) {
  116 + console.log(money, "有进来吗银行卡", advancek);
  117 + var user_id = getApp().globalData.user_id;
  118 + var store_id = os.stoid;
  119 + var recharge_type = 6;
  120 + var buynum = 1;
  121 + console.log(money, "有进来吗预存劵", advancek, user_id, store_id );
  122 + var e = this,
  123 + perpaid = "";
  124 + await getApp().request.promiseGet("/api/weshop/users/getPay", {
  125 + data: {
  126 + account: money,
  127 + yucun_id: advancek,
  128 + user_id: user_id,
  129 + store_id: store_id,
  130 + recharge_type: recharge_type,
  131 + buynum: buynum ,
  132 + }
  133 + }).then(res => {
  134 + console.log(res);
  135 +
  136 +
  137 + var msg = res.data.data;
  138 + var parentSn = msg.order_sn;
  139 + var store_id = os.stoid;
  140 + getApp().request.post("/api/weshop/order/pay/createRechargeOrder", {
  141 + data: {
  142 + parentSn: parentSn,
  143 + store_id: store_id
  144 + },
  145 + success: function (su) {
  146 + console.log("su是什么",su);
  147 + var n=su.data.data;
  148 + console.log("su是什么", su);
  149 +
  150 + e.weixinPay(n,
  151 + function () {
  152 + e.jumpPaymentPage();
  153 + }, function () {
  154 + getApp().showWarning("支付失败");
  155 + })
  156 + }
  157 + })
  158 + })
  159 + },
  160 + //------支付成功页面--------
  161 + jumpPaymentPage: function () {
  162 + wx.redirectTo({
  163 + url:"msg/msg",
  164 + });
  165 + },
  166 +
  167 + //------调起支付框--------
  168 + weixinPay: function (n, success, fail) {
  169 + wx.requestPayment({
  170 + timeStamp: String(n.timeStamp),
  171 + nonceStr: n.nonceStr,
  172 + package: n.packageValue,
  173 + signType: n.signType,
  174 + paySign: n.paySign,
  175 + success: function (n) {
  176 + console.log(n), getApp().showSuccess("支付成功!");
  177 + "function" == typeof success && success();
  178 + wx.redirectTo({
  179 + url: "../deposit/deposit"
  180 + });
  181 + },
  182 + fail: function (n) {
  183 + console.log(n), "requestPayment:fail" == n.errMsg ? getApp().showWarning("支付失败") : "requestPayment:fail cancel" == n.errMsg ? getApp().showWarning("您已取消支付") : getApp().showWarning("支付失败:" + n.errMsg.substr("requestPayment:fail ".length)),
  184 + "function" == typeof fail && fail();
  185 + }
  186 + });
  187 + },
105 188 })
106 189 \ No newline at end of file
... ...
packageA/pages/chongzhiDetails/chongzhiDetails.wxml
1 1 <!--packageA//pages/chongzhiDetails/chongzhiDetails.wxml-->
2 2 <view class="container">
3 3 <view>
4   - <view class="banner-container"><image class="img-block" src="../../../images/banner.jpg"></image></view>
5   -
6   -
7   -
  4 + <view class="banner-container">
  5 + <image class="img-block" src="{{url+show_img}}"
  6 + lazy-load="true" binderror="bind_err" data-errorimg="show_img" ></image></view>
  7 +
8 8 <view class="list">
9 9 <view class="title-container">
10 10 <view class="title">
... ... @@ -12,10 +12,17 @@
12 12 <view>你的美丽我来缔造</view>
13 13 </view>
14 14 </view>
15   -<!-- <block wx:for="{{list}}"> -->
  15 +
16 16 <view class="list-item flex" wx:for="{{result.givelist}}">
17   - <!-- 左 -->
18   - <view class="avatar"><text class="iconfont icon-meirong2"></text></view>
  17 + <!-- 左图片 -->
  18 + <view class="avatar">
  19 + <image wx:if="{{item.GiveType=='0'}}" src="{{url}}/miniapp/images/giftbag/gift05.png"></image><!-- 代金券 -->
  20 + <image wx:if="{{item.GiveType=='1'}}" src="{{url}}/miniapp/images/giftbag/gift02.png"></image><!-- 服务项目 -->
  21 + <image wx:if="{{item.GiveType=='2'}}" src="{{url}}/miniapp/images/giftbag/gift01.png"></image><!-- 商品 -->
  22 + <image wx:if="{{item.Integral>0}}" src="{{url}}/miniapp/images/giftbag/gift03.png"></image><!-- 积分 -->
  23 + <image wx:if="{{item.GradeSum>0}}" src="{{url}}/miniapp/images/giftbag/gift04.png"></image><!-- 成长值 -->
  24 + <image wx:if="{{item.PAdvanceItemId>0}}" src="{{url}}/miniapp/images/giftbag/gift01.png"></image><!-- 预存 -->
  25 + </view>
19 26 <!-- 右 -->
20 27 <view class="info">
21 28 <view class="">{{item.GiveName}}</view>
... ... @@ -23,23 +30,20 @@
23 30 <view class="t-r fs24 c-y">数量:{{item.Qty}}</view>
24 31 </view>
25 32 </view>
26   - <!-- </block> -->
27   -
28   -
  33 +
29 34 </view>
30 35  
31 36 </view>
32 37  
33   - <view class="btn-container">
34   - <text class="btn" bindtap="onUse">立即使用</text>
35   - </view>
36   -
37   - <view class="qr-container" wx:if="{{showCode}}" bindtap="onUse">
38   - <view class="qr">
39   - <!-- <view class="qr-img"><image class="img-block" src="../../../images/123456.jpg"></image></view> -->
40   - <qrcode id="qrcode" ></qrcode>
41   - <view>核销码:{{result.WriteOffCode}}</view>
42   - </view>
  38 + <view class="btn-container">
  39 + <text wx:if="{{type==0}}" data-advance="{{result.AdvanceItemId}}" data-money="{{result.NewSum}}"
  40 + class="btn" bindtap="go_buy">立即充值</text>
  41 + <block wx:else>
  42 + <text wx:if="{{result.AddType==0}}" class="btn" bindtap="onUse">立即使用</text>
  43 + <text wx:if="{{result.AddType==1}}" class="btn" >已核销</text>
  44 + </block>
43 45 </view>
  46 +
  47 + <qrcode id="qrcode" ></qrcode>
44 48  
45 49 </view>
... ...
packageA/pages/chongzhiDetails/chongzhiDetails.wxss
... ... @@ -79,6 +79,8 @@
79 79 text-align: center;
80 80 }
81 81  
  82 +.avatar image{ width: 100%; height: 100%;}
  83 +
82 84 .icon-meirong2 {
83 85 color: white;
84 86 font-size: 64rpx;
... ...
pages/user/deposit/prepaid/prepaid.js
... ... @@ -160,5 +160,10 @@ Page({
160 160 })
161 161 console.log("bb");
162 162  
  163 + },
  164 +
  165 + go_detail:function(e){
  166 + var id=e.currentTarget.dataset.id;
  167 + getApp().goto('/packageA/pages/chongzhiDetails/chongzhiDetails?id=' + id);
163 168 }
164 169 })
... ...
pages/user/deposit/prepaid/prepaid.wxml
... ... @@ -5,7 +5,7 @@
5 5 <image wx:if="{{idx % 4 == 2}}" class="picture" src="{{iurl+'miniapp/images/usermoney/yellow.png'}}"></image>
6 6 <image wx:if="{{idx % 4 == 3}}" class="picture" src="{{iurl+'miniapp/images/usermoney/blue.png'}}"></image>
7 7 <view class="info-container flex">
8   - <view class="left">
  8 + <view class="left" catchtap="go_detail" data-id="{{perpaid.Id}}">
9 9 <view>{{perpaid.ItemName}}</view>
10 10 <view class="pdv20">充{{perpaid.BeginSum}}<text>送{{perpaid.NewSum}}元</text></view>
11 11 <view wx:if="{{perpaid.ItemType==2}}">充值送大礼 ></view>
... ... @@ -13,7 +13,7 @@
13 13 <view class="right">备注:
14 14 <view class="">{{perpaid.ItemName}}</view>
15 15 <view wx:if="{{perpaid.ItemType==1}}" class="ljcz" bindtap="submit" data-name="{{perpaid.BeginSum}}"
16   - data-advance="{{perpaid.AdvanceItemId}}"data-money="{{perpaid.NewSum}}">立即充值</view>
  16 + data-advance="{{perpaid.AdvanceItemId}}" data-money="{{perpaid.NewSum}}">立即充值</view>
17 17  
18 18 <view wx:if="{{perpaid.ItemType==2}}" class="ljcz" bindtap="go_detail" data-advance="{{perpaid.AdvanceItemId}}">立即充值</view>
19 19 </view>
... ...