Files
wdsxh/unpackage/dist/build/mp-weixin/pagesMall/goods/order.js
2026-04-29 15:33:58 +08:00

1 line
8.7 KiB
JavaScript

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pagesMall/goods/order"],{"142d":function(t,e,o){"use strict";o.r(e);var i=o("fae8"),n=o.n(i);for(var a in i)["default"].indexOf(a)<0&&function(t){o.d(e,t,(function(){return i[t]}))}(a);e["default"]=n.a},"357b":function(t,e,o){},"90f0":function(t,e,o){"use strict";o.r(e);var i=o("d46a"),n=o("142d");for(var a in n)["default"].indexOf(a)<0&&function(t){o.d(e,t,(function(){return n[t]}))}(a);o("da07");var s=o("828b"),r=Object(s["a"])(n["default"],i["b"],i["c"],!1,null,null,null,!1,i["a"],void 0);e["default"]=r.exports},c38a:function(t,e,o){"use strict";(function(t,e){var i=o("47a9");o("aa6c");i(o("3240"));var n=i(o("90f0"));t.__webpack_require_UNI_MP_PLUGIN__=o,e(n.default)}).call(this,o("3223")["default"],o("df3c")["createPage"])},d46a:function(t,e,o){"use strict";o.d(e,"b",(function(){return i})),o.d(e,"c",(function(){return n})),o.d(e,"a",(function(){}));var i=function(){var t=this.$createElement,e=(this._self._c,this.loadEnd&&1==this.deliveryMethod?parseFloat(this.orderFreight).toFixed(2):null),o=this.loadEnd?this.getOrderAmount():null;this.$mp.data=Object.assign({},{$root:{g0:e,m0:o}})},n=[]},da07:function(t,e,o){"use strict";var i=o("357b"),n=o.n(i);n.a},fae8:function(t,e,o){"use strict";(function(t){var i=o("47a9");Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=i(o("7ca3")),a=o("8f59"),s=i(o("f5e9"));function r(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,i)}return o}function d(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?r(Object(o),!0).forEach((function(e){(0,n.default)(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}var c={components:{mallStore:function(){o.e("pagesMall/component/mall/store").then(function(){return resolve(o("9ee2"))}.bind(null,o)).catch(o.oe)},selectPicker:function(){o.e("pages/component/picker/select").then(function(){return resolve(o("519f"))}.bind(null,o)).catch(o.oe)},addressModal:function(){o.e("pagesMall/component/modal/address").then(function(){return resolve(o("e3d7"))}.bind(null,o)).catch(o.oe)},quantityModal:function(){o.e("pagesMall/component/modal/quantity").then(function(){return resolve(o("2570"))}.bind(null,o)).catch(o.oe)}},data:function(){return{pageShow:!1,loadEnd:!1,goodsData:[],deliveryMethod:1,addressData:{},orderFreight:0,isCartItem:!1,mallConfig:{}}},computed:d(d({},(0,a.mapState)({themeColor:function(t){return t.app.themeColor},iconMore:function(t){return s.default.svgToUrl("more",t.app.themeColor)},userMobile:function(t){return t.user.mobile},subscribeIds:function(t){return t.app.subscribeNotifyIds}})),{},{totalPrice:function(){var t=this.goodsData.reduce((function(t,e){return t+parseFloat(e.price)*parseInt(e.number)}),0);return parseFloat(t).toFixed(2)}}),onLoad:function(){var e=this;t.showLoading({title:"加载中"}),this.getMallConfig(),this.getGoodsDetails((function(){t.hideLoading(),e.loadEnd=!0}))},methods:{pageChange:function(t){this.pageShow=t},getGoodsDetails:function(e){var o,i,n,a=this;null!==(o=this.$store.state.app)&&void 0!==o&&null!==(i=o.mallOrder)&&void 0!==i&&null!==(n=i.list)&&void 0!==n&&n.length?(this.goodsData=this.$store.state.app.mallOrder.list||[],this.isCartItem=this.$store.state.app.mallOrder.isCartItem||!1,this.getAddress((function(){a.getPostage(e)}))):(t.hideLoading(),t.showModal({title:"提示",content:"请选择商品后下单",showCancel:!1,confirmText:"返回",confirmColor:this.themeColor,complete:function(){t.navigateBack()}}))},getMallConfig:function(){var e=this;this.$util.request("mall.config").then((function(o){1==o.code?e.mallConfig=o.data:t.showToast({title:o.msg,icon:"none"})})).catch((function(t){console.error("获取商城配置",t)}))},getAddress:function(e){var o=this;this.$util.request("mall.address.list",{is_default:1}).then((function(i){1==i.code?(i.data[0]&&(o.addressData=i.data[0]),e&&e()):(e&&e(),t.showToast({title:i.msg,icon:"none"}))})).catch((function(t){e&&e(),console.error("获取默认地址",t)}))},getPostage:function(e){var o=this;2!=this.deliveryMethod&&this.addressData&&this.addressData.id?this.$util.request("mall.getPostage",{pay_price:this.totalPrice,address_id:this.addressData.id}).then((function(i){e&&e(),1==i.code?o.orderFreight=parseFloat(i.data.price):t.showToast({title:i.msg,icon:"none"})})).catch((function(t){e&&e(),console.error("获取运费",t)})):e&&e()},bindPhoneNumber:function(e){var o=this;"getPhoneNumber:ok"==e.detail.errMsg?(t.showLoading({mask:!0,title:"加载中"}),t.login({provider:"weixin",success:function(i){var n=e.detail;n.code=i.code,o.$util.request("login.bindMobile",n).then((function(e){t.hideLoading(),1==e.code?(o.$store.commit("user/updateMobile",e.data.phoneNumber),o.submitOrder()):t.showToast({title:e.msg,icon:"none"})})).catch((function(e){t.hideLoading(),console.error("获取用户手机号码 ",e)}))},fail:function(){t.hideLoading(),t.showToast({icon:"none",title:"授权手机号失败,请重试"})}})):t.showToast({title:"获取手机号失败,请重新获取",icon:"none"})},openDeliveryMethod:function(){this.$refs.selectPicker.open([{id:1,name:"快递发货"},{id:2,name:"到店自提"}],this.deliveryMethod)},changeDeliveryMethod:function(e){this.deliveryMethod=e.id,1==e.id&&(t.showLoading({title:"加载中",mask:!0}),this.getPostage((function(){t.hideLoading()})))},chooseAddress:function(){this.$refs.addressModal.open(this.addressData.id)},changeAddress:function(t){this.addressData=t,this.getPostage()},toNavigation:function(){this.$util.toPage({mode:7,address:{latitude:this.mallConfig.latitude,longitude:this.mallConfig.longitude,address:this.mallConfig.address}})},onContact:function(){this.$util.toPage({mode:6,phone:this.mallConfig.mobile})},changeNumber:function(t,e){if(1==t){if(parseInt(this.goodsData[e].number)>1){var o=parseInt(this.goodsData[e].number)-1;this.changeQuantity(o,e)}}else if(2==t){var i=parseInt(this.goodsData[e].number)+1;this.changeQuantity(i,e)}else 3==t&&this.$refs.quantityModal.open(this.goodsData[e].number,e)},changeQuantity:function(e,o){var i=this;t.showLoading({mask:!0,title:"加载中"}),this.isCartItem?this.$util.request("mall.updateCartNumber",{goods_id:this.goodsData[o].id,number:e}).then((function(n){1==n.code?(i.$set(i.goodsData[o],"number",parseInt(e)),i.getPostage((function(){t.hideLoading()}))):(t.hideLoading(),t.showToast({title:n.msg,icon:"none"}))})).catch((function(e){t.hideLoading(),console.error("更新购物车商品数量",e)})):(this.$set(this.goodsData[o],"number",parseInt(e)),this.getPostage((function(){t.hideLoading()})))},getOrderAmount:function(){var t=0;return t=2==this.deliveryMethod?parseFloat(this.totalPrice):parseFloat(this.totalPrice)+parseFloat(this.orderFreight),parseFloat(t).toFixed(2)},submitOrder:function(){var e=this;1!=this.deliveryMethod||this.addressData&&this.addressData.id?(t.showLoading({title:"提交中",mask:!0}),this.subscribeMessage((function(){var o={goods_id:e.goodsData.map((function(t){return t.id})).join(),buy_now:e.isCartItem?2:1,delivery_method:e.deliveryMethod};e.isCartItem||(o.number=e.goodsData[0].number),1==e.deliveryMethod&&(o.address_id=e.addressData.id),e.$util.request("mall.createOrder",o).then((function(o){t.hideLoading(),1==o.code?e.$util.toPage({mode:2,path:"/pagesMall/order/payment?money=".concat(e.getOrderAmount(),"&id=").concat(o.data.order_id)}):t.showToast({title:o.msg,icon:"none"})})).catch((function(t){console.error("创建订单",t)}))}))):t.showToast({title:"请选择收货地址",icon:"none"})},subscribeMessage:function(e){var o,i,n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=[];null!==(o=this.subscribeIds)&&void 0!==o&&o.applet_order_shipping_notification&&s.push(this.subscribeIds.applet_order_shipping_notification),null!==(i=this.subscribeIds)&&void 0!==i&&i.applet_confirm_receipt_notification&&s.push(this.subscribeIds.applet_confirm_receipt_notification),t.requestSubscribeMessage({tmplIds:s,success:function(){e()},fail:function(o){20004==o.errCode?(t.hideLoading(),t.showModal({title:"提示",content:"请前往设置打开接受通知",confirmColor:n.themeColor,confirmText:"继续提交",success:function(t){t.confirm&&e()}})):o.errCode?(t.hideLoading(),t.showModal({title:"提示",content:"消息订阅失败,无法接收到订单通知,错误码:"+o.errCode,confirmColor:n.themeColor,confirmText:"继续提交",success:function(t){t.confirm&&e()}})):++a>3?n.subscribeMessage(e,a):e()}})}}};e.default=c}).call(this,o("df3c")["default"])}},[["c38a","common/runtime","common/vendor"]]]);