1
Showing
3 changed files
with
95 additions
and
30 deletions
| ... | @@ -34,9 +34,9 @@ Component({ | ... | @@ -34,9 +34,9 @@ Component({ |
| 34 | provinceList: [], | 34 | provinceList: [], |
| 35 | cityList: [], | 35 | cityList: [], |
| 36 | districtList: [], | 36 | districtList: [], |
| 37 | provinceIndex: 0, | 37 | provinceIndex: -1, |
| 38 | cityIndex: 0, | 38 | cityIndex: -1, |
| 39 | districtIndex: 0, | 39 | districtIndex: -1, |
| 40 | addressList: [], | 40 | addressList: [], |
| 41 | total: 0, | 41 | total: 0, |
| 42 | curAddress: null, | 42 | curAddress: null, |
| ... | @@ -135,7 +135,6 @@ Component({ | ... | @@ -135,7 +135,6 @@ Component({ |
| 135 | */ | 135 | */ |
| 136 | onShowLocHandler(evt) { | 136 | onShowLocHandler(evt) { |
| 137 | let item = getBindtapData(evt); | 137 | let item = getBindtapData(evt); |
| 138 | |||
| 139 | wx.openLocation({ | 138 | wx.openLocation({ |
| 140 | latitude: item.latitude, // 纬度,范围为-90~90,负数表示南纬 | 139 | latitude: item.latitude, // 纬度,范围为-90~90,负数表示南纬 |
| 141 | longitude: item.longitude, // 经度,范围为-180~180,负数表示西经 | 140 | longitude: item.longitude, // 经度,范围为-180~180,负数表示西经 |
| ... | @@ -175,7 +174,7 @@ Component({ | ... | @@ -175,7 +174,7 @@ Component({ |
| 175 | this.setData({ | 174 | this.setData({ |
| 176 | provinceList: result | 175 | provinceList: result |
| 177 | }) | 176 | }) |
| 178 | console.log("getProvince result:", result); | 177 | // console.log("getProvince result:", result); |
| 179 | }) | 178 | }) |
| 180 | }); | 179 | }); |
| 181 | }, | 180 | }, | ... | ... |
| 1 | import { | 1 | |
| 2 | wishbillGiftQuery | ||
| 3 | } from '../../const/custom-data'; | ||
| 4 | import { | 2 | import { |
| 5 | getBindtapData, | 3 | getBindtapData, |
| 6 | pxToRpx | 4 | pxToRpx, |
| 5 | getLocalDistance | ||
| 7 | } from '../../utils/util'; | 6 | } from '../../utils/util'; |
| 8 | import Date from '../../utils/date'; | 7 | import Date from '../../utils/date'; |
| 9 | import QR from '../../utils/qrcode' | 8 | import QR from '../../utils/qrcode' |
| ... | @@ -21,40 +20,67 @@ Page({ | ... | @@ -21,40 +20,67 @@ Page({ |
| 21 | }, | 20 | }, |
| 22 | onShareAppMessage() {}, | 21 | onShareAppMessage() {}, |
| 23 | onLoad(options) { | 22 | onLoad(options) { |
| 24 | // let wishInfo = options; | ||
| 25 | let wishInfo = wishbillGiftQuery.order; | ||
| 26 | let couponInfo = wishInfo.coupon; | ||
| 27 | 23 | ||
| 28 | // 设置起止时间 | 24 | // let giftData = app.globalData.curCoupon; |
| 29 | couponInfo.startDateStr = new Date(couponInfo.startDate).toString("yyyy.MM.dd"); | 25 | // let wishInfo = giftData.order; |
| 30 | couponInfo.endDateStr = new Date(couponInfo.endDate).toString("yyyy.MM.dd"); | 26 | let couponInfo = app.globalData.curCoupon; |
| 31 | |||
| 32 | // 判断是否使用 | ||
| 33 | // 自提券 使用状态(0=未使用 1=已过期,2=已使用) | ||
| 34 | let used = couponInfo.state != 0; | ||
| 35 | // used = true; | ||
| 36 | 27 | ||
| 37 | // 设置数据 | 28 | // 设置数据 |
| 38 | this.setData({ | 29 | this.setData({ |
| 39 | wishInfo: wishInfo, | 30 | // wishInfo: wishInfo, |
| 40 | couponInfo: couponInfo, | 31 | couponInfo: couponInfo |
| 41 | used: used | ||
| 42 | }) | 32 | }) |
| 33 | |||
| 43 | this.initData(); | 34 | this.initData(); |
| 44 | }, | 35 | }, |
| 45 | initData() { | 36 | initData() { |
| 37 | let _this = this; | ||
| 46 | app.queryIndex().then((result) => { | 38 | app.queryIndex().then((result) => { |
| 47 | this.setData({ | 39 | this.setData({ |
| 48 | userInfo: app.globalData.userInfo | 40 | userInfo: app.globalData.userInfo |
| 49 | }) | 41 | }) |
| 50 | 42 | ||
| 51 | // 设置二维码 | 43 | let wishInfo = this.data.wishInfo; |
| 52 | let couponInfo = this.data.couponInfo; | 44 | let couponInfo = this.data.couponInfo; |
| 45 | |||
| 46 | // 设置二维码 | ||
| 53 | let qrSize = this.setCanvasSize(340); | 47 | let qrSize = this.setCanvasSize(340); |
| 54 | console.log("couponInfo:", couponInfo); | 48 | console.log("couponInfo:", couponInfo); |
| 55 | let codeContent = couponInfo.couponCode || ''; | 49 | let codeContent = couponInfo.couponCode || ''; |
| 56 | this.createQrCode(codeContent, 'qrcanvas', qrSize.w, qrSize.h); | 50 | this.createQrCode(codeContent, 'qrcanvas', qrSize.w, qrSize.h); |
| 57 | 51 | ||
| 52 | // 判断是否使用 | ||
| 53 | // 自提券 使用状态(0=未使用 1=已过期,2=已使用) | ||
| 54 | let used = couponInfo.state != 0; | ||
| 55 | |||
| 56 | // 设置起止时间 | ||
| 57 | couponInfo.startDateStr = new Date(couponInfo.startDate).toString("yyyy.MM.dd"); | ||
| 58 | couponInfo.endDateStr = new Date(couponInfo.endDate).toString("yyyy.MM.dd"); | ||
| 59 | |||
| 60 | // 设置数据 | ||
| 61 | this.setData({ | ||
| 62 | couponInfo: couponInfo, | ||
| 63 | used: used | ||
| 64 | }) | ||
| 65 | |||
| 66 | |||
| 67 | // 设置坐标 | ||
| 68 | // wx.getLocation({ | ||
| 69 | // type: 'gcj02', | ||
| 70 | // success(res) { | ||
| 71 | // let targetLocation = { | ||
| 72 | // latitude: wishInfo.latitude, | ||
| 73 | // longitude: wishInfo.longitude, | ||
| 74 | // } | ||
| 75 | // let distance = getLocalDistance(res, targetLocation).dis; | ||
| 76 | // wishInfo.distance = distance; | ||
| 77 | // console.log("distance:", distance); | ||
| 78 | // _this.setData({ | ||
| 79 | // wishInfo: wishInfo | ||
| 80 | // }) | ||
| 81 | // } | ||
| 82 | // }) | ||
| 83 | |||
| 58 | }) | 84 | }) |
| 59 | }, | 85 | }, |
| 60 | /** | 86 | /** |
| ... | @@ -75,7 +101,7 @@ Page({ | ... | @@ -75,7 +101,7 @@ Page({ |
| 75 | wxLocation() { | 101 | wxLocation() { |
| 76 | let _this = this; | 102 | let _this = this; |
| 77 | wx.getLocation({ | 103 | wx.getLocation({ |
| 78 | type: 'wgs84', | 104 | type: 'gcj02', |
| 79 | success(res) { | 105 | success(res) { |
| 80 | _this.setData({ | 106 | _this.setData({ |
| 81 | location: res | 107 | location: res |
| ... | @@ -122,6 +148,27 @@ Page({ | ... | @@ -122,6 +148,27 @@ Page({ |
| 122 | } | 148 | } |
| 123 | }) | 149 | }) |
| 124 | }, | 150 | }, |
| 151 | |||
| 152 | /** | ||
| 153 | * 显示位置 | ||
| 154 | * @param {*} e | ||
| 155 | */ | ||
| 156 | onShowLocHandler(evt) { | ||
| 157 | let item = this.data.wishInfo; | ||
| 158 | console.log("item:", item); | ||
| 159 | |||
| 160 | wx.openLocation({ | ||
| 161 | latitude: item.latitude, // 纬度,范围为-90~90,负数表示南纬 | ||
| 162 | longitude: item.longitude, // 经度,范围为-180~180,负数表示西经 | ||
| 163 | scale: 18, // 缩放比例 | ||
| 164 | name: item.storeName, // 位置名 | ||
| 165 | address: item.storeAddress, // 地址的详细说明 | ||
| 166 | success: function (res) { | ||
| 167 | // success | ||
| 168 | } | ||
| 169 | }) | ||
| 170 | }, | ||
| 171 | |||
| 125 | createQrCode(content, canvasId, cavW, cavH) { | 172 | createQrCode(content, canvasId, cavW, cavH) { |
| 126 | //调用插件中的draw方法,绘制二维码图片 | 173 | //调用插件中的draw方法,绘制二维码图片 |
| 127 | QR.api.draw(content, canvasId, cavW, cavH); | 174 | QR.api.draw(content, canvasId, cavW, cavH); |
| ... | @@ -182,11 +229,29 @@ Page({ | ... | @@ -182,11 +229,29 @@ Page({ |
| 182 | case "_evt_submit_store_complete": | 229 | case "_evt_submit_store_complete": |
| 183 | // 刷新状态 | 230 | // 刷新状态 |
| 184 | this.hideMask(); | 231 | this.hideMask(); |
| 185 | wx.showModal({ | 232 | app.post({ |
| 186 | content: '预约成功', | 233 | url: app.api.wishbillGiftQuery, |
| 187 | showCancel: false, | 234 | data: { |
| 188 | success(res) {} | 235 | instanceCode: curData.instanceCode |
| 189 | }); | 236 | } |
| 237 | }).then((result) => { | ||
| 238 | |||
| 239 | // 重新拉取数据 | ||
| 240 | let giftData = result; | ||
| 241 | let wishInfo = giftData.order; | ||
| 242 | let couponInfo = wishInfo.coupon; | ||
| 243 | this.setData({ | ||
| 244 | wishInfo: wishInfo, | ||
| 245 | couponInfo: couponInfo | ||
| 246 | }) | ||
| 247 | this.initData(); | ||
| 248 | |||
| 249 | wx.showModal({ | ||
| 250 | content: '预约成功', | ||
| 251 | showCancel: false, | ||
| 252 | success(res) {} | ||
| 253 | }); | ||
| 254 | }) | ||
| 190 | break; | 255 | break; |
| 191 | 256 | ||
| 192 | default: | 257 | default: | ... | ... |
| ... | @@ -31,6 +31,7 @@ Page({ | ... | @@ -31,6 +31,7 @@ Page({ |
| 31 | onShowDetailHandler(evt) { | 31 | onShowDetailHandler(evt) { |
| 32 | let curData = getBindtapData(evt); | 32 | let curData = getBindtapData(evt); |
| 33 | app.globalData.curCoupon = curData; | 33 | app.globalData.curCoupon = curData; |
| 34 | // app.globalData.giftData = curData; | ||
| 34 | app.router.push({ | 35 | app.router.push({ |
| 35 | path: "couponDetail" | 36 | path: "couponDetail" |
| 36 | }) | 37 | }) | ... | ... |
-
Please register or sign in to post a comment