From ffdf4bb5295ab09da11886919ed796852e6606bf Mon Sep 17 00:00:00 2001 From: zhangjing <994797151@qq.com> Date: Tue, 15 Jun 2021 13:32:20 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/interfaces/index.js | 6 ++- app.json | 7 ++-- pages/index/index.js | 75 +++++++++++++++++++++++++++++++++----- pages/index/index.wxml | 4 +- pages/washcar/washcar.js | 69 +++++++++++++++++++++++++++++++++++ pages/washcar/washcar.json | 3 ++ pages/washcar/washcar.wxml | 1 + pages/washcar/washcar.wxss | 1 + project.config.json | 2 +- 9 files changed, 151 insertions(+), 17 deletions(-) create mode 100644 pages/washcar/washcar.js create mode 100644 pages/washcar/washcar.json create mode 100644 pages/washcar/washcar.wxml create mode 100644 pages/washcar/washcar.wxss diff --git a/api/interfaces/index.js b/api/interfaces/index.js index 366ad15..a650a2d 100644 --- a/api/interfaces/index.js +++ b/api/interfaces/index.js @@ -70,6 +70,9 @@ const fridayInfo = (werlfare_id, address_id, is_deliver) => req({url: "welfare/o //周五福利-支付 const fridayPay = (trade_no) => req({url: "payments/welfare/wechat",method: "POST", data: {trade_no: trade_no}}) +//洗车券-获取跳转地址 +const washcarUrl = (welfare_id, right_config_id) => req({url: "washcar/infourl", data: {welfare_id: welfare_id, right_config_id: right_config_id}}) + export default({ index, choice, @@ -93,5 +96,6 @@ export default({ newCity, newidxCity, fridayInfo, - fridayPay + fridayPay, + washcarUrl }) diff --git a/app.json b/app.json index b0928fd..2d8f097 100644 --- a/app.json +++ b/app.json @@ -25,7 +25,8 @@ "pages/packet/packet", "pages/frozen/frozen", "pages/welfare/welfare", - "pages/classify/classify" + "pages/classify/classify", + "pages/washcar/washcar" ], "window": { "backgroundTextStyle": "light", @@ -61,8 +62,8 @@ }, "plugins": { "sendCoupon": { - "version" : "1.2.0", - "provider": "wxf3f436ba9bd4be7b" + "version": "1.2.0", + "provider": "wxf3f436ba9bd4be7b" } } } \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js index fb3abe9..0d2bd30 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -181,9 +181,11 @@ Page({ * 周五福利抢购 */ Snapup(e) { - let canBuy = e.currentTarget.dataset.can, - canText = e.currentTarget.dataset.text, - canId = e.currentTarget.dataset.id + let canBuy = e.currentTarget.dataset.can, + canText = e.currentTarget.dataset.text, + canId = e.currentTarget.dataset.id, + canFrom = e.currentTarget.dataset.from, + canRightid = e.currentTarget.dataset.rightid if(!canBuy) { wx.showToast({ title : canText, @@ -193,23 +195,76 @@ Page({ return } - // 跳转分类页 - wx.navigateTo({ - url: '/pages/welfare/welfare?id=' + canId + wx.getStorage({ + key : 'token', + success:res=>{ + if(canFrom == 'washcar') { + wx.$api.index.washcarUrl(canId, canRightid).then(res=>{ + const newUrl = res.data + let url= encodeURIComponent(newUrl) + wx.redirectTo({ + // 跳转到webview页面 + url: `/pages/washcar/washcar?url=${url}` + }); + }).catch(err=>{ + if(!err.login){ + // 写入缓存 + wx.setStorage({ + key : 'token', + data : '' + }) + } + }) + } else { + // 跳转分类页 + wx.navigateTo({ + url: '/pages/welfare/welfare?id=' + canId + }) + } + }, + fail: (err) => { + wx.navigateTo({ + url: "/pages/login/login" + }) + } }) + }, /** * 活动中心权益跳转详情 */ rightNav(e) { - let id = e.currentTarget.dataset.id + let id = e.currentTarget.dataset.id, + from = e.currentTarget.dataset.from, + rightid = e.currentTarget.dataset.rightid + wx.getStorage({ key : 'token', success:res=>{ - wx.navigateTo({ - url: '/pages/rights/rights?id=' + id - }) + if(from == 'washcar') { + wx.$api.index.washcarUrl(id, rightid).then(res=>{ + const newUrl = res.data + let url= encodeURIComponent(newUrl) + wx.redirectTo({ + // 跳转到webview页面 + url: `/pages/washcar/washcar?url=${url}` + }); + }).catch(err=>{ + if(!err.login){ + // 写入缓存 + wx.setStorage({ + key : 'token', + data : '' + }) + } + }) + } else { + // 跳转分类页 + wx.navigateTo({ + url: '/pages/rights/rights?id=' + id + }) + } }, fail: (err) => { wx.navigateTo({ diff --git a/pages/index/index.wxml b/pages/index/index.wxml index db5acf4..91ccd1d 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -68,7 +68,7 @@ + data-id="{{item.right_config_id}}" data-from="{{item.from}}" data-rightid="{{item.right_config_id}}"> {{item.title}} @@ -90,7 +90,7 @@ 周五会员福利日 + data-text="{{item.code_text}}" data-can="{{item.canBuy}}" data-id="{{item.welfare_id}}" data-from="{{item.right.from}}" data-rightId="{{item.right.right_config_id}}"> diff --git a/pages/washcar/washcar.js b/pages/washcar/washcar.js new file mode 100644 index 0000000..abacc70 --- /dev/null +++ b/pages/washcar/washcar.js @@ -0,0 +1,69 @@ +// pages/webView/webView.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + url:'' + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad (options) { + console.log(options.url) + this.setData({ + url : decodeURIComponent(options.url) + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/washcar/washcar.json b/pages/washcar/washcar.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/washcar/washcar.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/washcar/washcar.wxml b/pages/washcar/washcar.wxml new file mode 100644 index 0000000..77a6354 --- /dev/null +++ b/pages/washcar/washcar.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pages/washcar/washcar.wxss b/pages/washcar/washcar.wxss new file mode 100644 index 0000000..7a77606 --- /dev/null +++ b/pages/washcar/washcar.wxss @@ -0,0 +1 @@ +/* pages/washcar/washcar.wxss */ \ No newline at end of file diff --git a/project.config.json b/project.config.json index 070976e..35eb3c7 100644 --- a/project.config.json +++ b/project.config.json @@ -23,7 +23,7 @@ "compileHotReLoad": false, "useMultiFrameRuntime": true, "useApiHook": true, - "useApiHostProcess": false, + "useApiHostProcess": true, "babelSetting": { "ignore": [], "disablePlugins": [],