Commit 58eeb2dd83cdea22582d0bc8bc79b3275137f59a
1 parent
3542a17f
地址填写调用原生APP的地址填写
Showing
3 changed files
with
95 additions
and
45 deletions
src/components/appAddressToast/appAddressToast.vue
| ... | ... | @@ -14,13 +14,13 @@ |
| 14 | 14 | {{ addressInfo.phone }} |
| 15 | 15 | </div> |
| 16 | 16 | </div> |
| 17 | - <div @click="changeAddress()" class="btn">更换</div> | |
| 17 | + <div @click="changeAddress(addressInfo)" class="btn">更换</div> | |
| 18 | 18 | </div> |
| 19 | 19 | <div v-if="addressInfo.address" class="info"> |
| 20 | 20 | {{ addressInfo.address }} |
| 21 | 21 | </div> |
| 22 | 22 | </div> |
| 23 | - <div class="tooltips" v-else @click="changeAddress()"> | |
| 23 | + <div class="tooltips" v-else @click="changeAddress(addressInfo)"> | |
| 24 | 24 | 您未填写地址,去填写 |
| 25 | 25 | </div> |
| 26 | 26 | </div> |
| ... | ... | @@ -51,8 +51,6 @@ export default { |
| 51 | 51 | return { |
| 52 | 52 | itemInfo: null, |
| 53 | 53 | addressInfo: null, |
| 54 | - goodsId: this.$route.query.goodsId || null, // 兑换商品ID | |
| 55 | - orderId: this.$route.query.orderId || null, // 订单ID 先兑换后填地址使用 | |
| 56 | 54 | // drawRecordItemInfo: null // 中奖记录单条信息 |
| 57 | 55 | }; |
| 58 | 56 | }, |
| ... | ... | @@ -64,15 +62,17 @@ export default { |
| 64 | 62 | // 父组件点击兑换调用子组件传值商品商品信息 |
| 65 | 63 | getItemInfo (content, orderId) { |
| 66 | 64 | this.itemInfo = content; |
| 65 | + // 获取订单ID | |
| 67 | 66 | if (orderId) { |
| 68 | - this.orderId = orderId | |
| 69 | - } else { | |
| 70 | - this.goodsId = content.id; // 获取需要兑换商品的ID | |
| 67 | + this.$set(this.itemInfo, "id", orderId) | |
| 71 | 68 | } |
| 72 | - // 获取商品信息接口 | |
| 73 | - this.luckDrawGift(content.id); | |
| 74 | 69 | // 获取首选地址接口 |
| 75 | - this.myFirstAddress(); | |
| 70 | + this.myFirstAddress(this.itemInfo); | |
| 71 | + }, | |
| 72 | + // app地址信息选中回调 | |
| 73 | + getAppAddressInfo (content) { | |
| 74 | + // 选中赋值给addressInfo | |
| 75 | + this.addressInfo = content; | |
| 76 | 76 | }, |
| 77 | 77 | // 我的首选地址 |
| 78 | 78 | /** |
| ... | ... | @@ -130,22 +130,17 @@ export default { |
| 130 | 130 | * 确定 |
| 131 | 131 | */ |
| 132 | 132 | confirm () { |
| 133 | - // 兑换商品的ID分两种一种是订单ID填写地址;一种是有商品地址填写地址 | |
| 134 | - let orderInfo = { | |
| 135 | - addressId: null, | |
| 136 | - id: null, // 兑换商品ID | |
| 137 | - }; | |
| 138 | 133 | // 最新地址信息回传给父组件 |
| 139 | - this.$parent.addressInfo = this.addressInfo; | |
| 140 | - this.addLuckDrawAddress(orderInfo); | |
| 134 | + // this.$parent.addressInfo = this.addressInfo; | |
| 135 | + this.addLuckDrawAddress(); | |
| 141 | 136 | // 隐藏弹框 |
| 142 | 137 | this.$parent.pointsToast_control = false; |
| 143 | 138 | }, |
| 144 | 139 | // 更改地址跳转原生 |
| 145 | - changeAddress () { | |
| 140 | + changeAddress (addressInfo) { | |
| 146 | 141 | // 进入赛场传值给原生toId |
| 147 | 142 | var result = prompt( |
| 148 | - "jiaShen://enterExamination?toId=" + item.toId | |
| 143 | + "wjjshop://selectAddress" + (addressInfo && addressInfo.id ? ("?addressId=" + addressInfo.id) : "") | |
| 149 | 144 | ); |
| 150 | 145 | }, |
| 151 | 146 | // 提交中奖的商品信息 |
| ... | ... | @@ -155,22 +150,21 @@ export default { |
| 155 | 150 | * *@param {string} id [商品id] |
| 156 | 151 | * *@param {string} id_card [身份证id] |
| 157 | 152 | */ |
| 158 | - addLuckDrawAddress (orderInfo) { | |
| 153 | + addLuckDrawAddress () { | |
| 159 | 154 | // 加载中提示 |
| 160 | 155 | Indicator.open("加载中..."); |
| 161 | - | |
| 162 | 156 | // 请求接口 |
| 163 | 157 | this.http( |
| 164 | 158 | "/Api/" + this.getApiVersion().LuckDraw + "/addLuckIntegralAddress", |
| 165 | 159 | { |
| 166 | 160 | uid: this.getStore("uid"), |
| 167 | - addressId: orderInfo.addressId, | |
| 168 | - id: orderInfo.id // 商品ID | |
| 161 | + addressId: this.addressInfo.id, | |
| 162 | + id: this.itemInfo.id // 商品ID | |
| 169 | 163 | }, |
| 170 | 164 | this.addLuckDrawAddressCallback, |
| 171 | 165 | { |
| 172 | - method: "POST", | |
| 173 | - ext: orderInfo | |
| 166 | + method: "POST" | |
| 167 | + // ext: this.itemInfo | |
| 174 | 168 | } |
| 175 | 169 | ); |
| 176 | 170 | }, |
| ... | ... | @@ -186,7 +180,7 @@ export default { |
| 186 | 180 | // 返回处理 |
| 187 | 181 | if (res.code == 200) { |
| 188 | 182 | Toast("提交成功等待发货"); |
| 189 | - this.$emit("toUpdate", ext.ext, this.addressInfo); | |
| 183 | + this.$emit("toUpdate", this.itemInfo, this.addressInfo); | |
| 190 | 184 | } else { |
| 191 | 185 | // 兑换礼品失败 |
| 192 | 186 | Toast(res.message); |
| ... | ... | @@ -198,5 +192,5 @@ export default { |
| 198 | 192 | |
| 199 | 193 | <!-- Add "scoped" attribute to limit CSS to this component only --> |
| 200 | 194 | <style rel="stylesheet/less" lang="less"> |
| 201 | -@import './addressToast'; | |
| 195 | +@import './appAddressToast'; | |
| 202 | 196 | </style> | ... | ... |
src/pages/goodDetails/goodDetails.vue
| ... | ... | @@ -103,7 +103,7 @@ |
| 103 | 103 | </div> |
| 104 | 104 | </div> |
| 105 | 105 | <!-- 地址信息组件 --> |
| 106 | - <h5-address-toast ref="itemsInfo" @toUpdate="toLinkPointsMall" v-show="pointsToast_control"></h5-address-toast> | |
| 106 | + <app-address-toast ref="itemsInfo" @toUpdate="toLinkPointsMall" v-show="pointsToast_control"></app-address-toast> | |
| 107 | 107 | </div> |
| 108 | 108 | </template> |
| 109 | 109 | |
| ... | ... | @@ -113,7 +113,7 @@ import callAppBox from "@/components/callAppBox/callAppBox"; |
| 113 | 113 | import swiper from "@/components/swiper/swiper"; |
| 114 | 114 | import backBox from "@/components/backBox/backBox"; |
| 115 | 115 | import columnListBox from "@/components/columnListBox/columnListBox"; |
| 116 | -import h5AddressToast from "@/components/h5AddressToast/h5AddressToast"; | |
| 116 | +import appAddressToast from "@/components/appAddressToast/appAddressToast"; | |
| 117 | 117 | import { Toast, Indicator } from "mint-ui"; |
| 118 | 118 | export default { |
| 119 | 119 | name: 'goodDetails', |
| ... | ... | @@ -122,7 +122,7 @@ export default { |
| 122 | 122 | banner: null, |
| 123 | 123 | goodsInfo: null, |
| 124 | 124 | backs: null, // 后退按钮组 |
| 125 | - pointsToast_control: this.$route.query.pointsToast_control, | |
| 125 | + pointsToast_control: false, | |
| 126 | 126 | isExchange: false, // 是否已经兑换 |
| 127 | 127 | } |
| 128 | 128 | }, |
| ... | ... | @@ -132,7 +132,7 @@ export default { |
| 132 | 132 | swiper, |
| 133 | 133 | backBox, |
| 134 | 134 | columnListBox, |
| 135 | - h5AddressToast | |
| 135 | + appAddressToast | |
| 136 | 136 | }, |
| 137 | 137 | //静态 |
| 138 | 138 | props: [ |
| ... | ... | @@ -385,6 +385,13 @@ export default { |
| 385 | 385 | Toast("获取积分商品详情页失败"); |
| 386 | 386 | } |
| 387 | 387 | }, |
| 388 | + /** | |
| 389 | + * app选中地址回选 | |
| 390 | + * @param {Object} addressInfo [服务器返回数据] | |
| 391 | + */ | |
| 392 | + appSelectAddressCallback (addressInfo) { | |
| 393 | + this.$refs.itemsInfo.getAppAddressInfo(addressInfo); | |
| 394 | + }, | |
| 388 | 395 | }, |
| 389 | 396 | //请求数据 |
| 390 | 397 | created () { |
| ... | ... | @@ -427,17 +434,38 @@ export default { |
| 427 | 434 | |
| 428 | 435 | }, |
| 429 | 436 | mounted () { |
| 437 | + var that = this; | |
| 438 | + window["appSelectAddressCallback"] = function (result) { | |
| 439 | + that.appSelectAddressCallback(result); | |
| 440 | + }; | |
| 430 | 441 | // 如果是App外,设置唤起App和微信内分享参数 |
| 431 | - if (!this.isCNLive.value) { | |
| 432 | - // 设置积分首页唤起app参数 | |
| 433 | - if (typeof this.$parent.getOpenApp === "function") { | |
| 434 | - this.$parent.getOpenApp({ | |
| 435 | - type: 46, | |
| 436 | - id: this.$route.query.goodsId, | |
| 437 | - url: "" | |
| 438 | - }); | |
| 439 | - } | |
| 440 | - } | |
| 442 | + // if (!this.isCNLive.value) { | |
| 443 | + // // 设置积分首页唤起app参数 | |
| 444 | + // if (typeof this.$parent.getOpenApp === "function") { | |
| 445 | + // this.$parent.getOpenApp({ | |
| 446 | + // type: 46, | |
| 447 | + // id: this.$route.query.goodsId, | |
| 448 | + // url: "" | |
| 449 | + // }); | |
| 450 | + // } | |
| 451 | + // } | |
| 452 | + // // 地址回选原生回调 | |
| 453 | + // if (this.isiPhone.value) { | |
| 454 | + // var that = this; | |
| 455 | + // function resolution (data) { | |
| 456 | + // that.appSelectAddressCallback(); | |
| 457 | + // } | |
| 458 | + // this.$bridge.registerHandler("appSelectAddressCallback", function ( | |
| 459 | + // data, | |
| 460 | + // responseCallback | |
| 461 | + // ) { | |
| 462 | + // resolution(data); | |
| 463 | + | |
| 464 | + // responseCallback(data); | |
| 465 | + // }); | |
| 466 | + // } else if (this.isAndroid.value) { | |
| 467 | + | |
| 468 | + // } | |
| 441 | 469 | }, |
| 442 | 470 | destroyed () { |
| 443 | 471 | // 隐藏通用浮层 | ... | ... |
src/pages/pointsExchangeRecords/pointsExchangeRecords.vue
| ... | ... | @@ -46,14 +46,14 @@ |
| 46 | 46 | 没有更多了 |
| 47 | 47 | </div> |
| 48 | 48 | <!-- 地址信息组件 --> |
| 49 | - <h5-address-toast ref="itemsInfo" @toUpdate="updateAddressInfo" v-show="pointsToast_control"></h5-address-toast> | |
| 49 | + <app-address-toast ref="itemsInfo" @toUpdate="updateAddressInfo" v-show="pointsToast_control"></app-address-toast> | |
| 50 | 50 | </div> |
| 51 | 51 | </template> |
| 52 | 52 | |
| 53 | 53 | <script> |
| 54 | 54 | // 引入组件 |
| 55 | 55 | import { Toast, Indicator } from "mint-ui"; |
| 56 | -import h5AddressToast from "@/components/h5AddressToast/h5AddressToast"; | |
| 56 | +import appAddressToast from "@/components/appAddressToast/appAddressToast"; | |
| 57 | 57 | export default { |
| 58 | 58 | data () { |
| 59 | 59 | return { |
| ... | ... | @@ -67,7 +67,7 @@ export default { |
| 67 | 67 | }, |
| 68 | 68 | //部件 |
| 69 | 69 | components: { |
| 70 | - h5AddressToast | |
| 70 | + appAddressToast | |
| 71 | 71 | }, |
| 72 | 72 | //静态 |
| 73 | 73 | props: [ |
| ... | ... | @@ -218,7 +218,14 @@ export default { |
| 218 | 218 | // 后退 |
| 219 | 219 | window.history.go(-1); |
| 220 | 220 | } |
| 221 | - } | |
| 221 | + }, | |
| 222 | + /** | |
| 223 | + * app选中地址回选 | |
| 224 | + * @param {Object} addressInfo [服务器返回数据] | |
| 225 | + */ | |
| 226 | + appSelectAddressCallback (addressInfo) { | |
| 227 | + this.$refs.itemsInfo.getAppAddressInfo(addressInfo); | |
| 228 | + }, | |
| 222 | 229 | }, |
| 223 | 230 | //请求数据 |
| 224 | 231 | created () { |
| ... | ... | @@ -233,6 +240,27 @@ export default { |
| 233 | 240 | } |
| 234 | 241 | }, |
| 235 | 242 | mounted () { |
| 243 | + // 地址回选原生回调 | |
| 244 | + var that = this; | |
| 245 | + window["appSelectAddressCallback"] = function (result) { | |
| 246 | + that.appSelectAddressCallback(result); | |
| 247 | + }; | |
| 248 | + // if (this.plat == "i") { | |
| 249 | + // var that = this; | |
| 250 | + // function resolution (data) { | |
| 251 | + // that.appSelectAddressCallback(); | |
| 252 | + // } | |
| 253 | + // this.$bridge.registerHandler("appSelectAddressCallback", function ( | |
| 254 | + // data, | |
| 255 | + // responseCallback | |
| 256 | + // ) { | |
| 257 | + // resolution(data); | |
| 258 | + | |
| 259 | + // responseCallback(data); | |
| 260 | + // }); | |
| 261 | + // } else if (this.plat == "a") { | |
| 262 | + | |
| 263 | + // } | |
| 236 | 264 | } |
| 237 | 265 | } |
| 238 | 266 | </script> | ... | ... |