diff --git a/common/js/goods_detail_base.js b/common/js/goods_detail_base.js index 53ef66e..2fe192a 100644 --- a/common/js/goods_detail_base.js +++ b/common/js/goods_detail_base.js @@ -183,7 +183,7 @@ export default { }; if (this.$refs.goodsPromotion) this.$refs.goodsPromotion.refresh(this.goodsSkuDetail.goods_promotion); - if (this.goodsRoute != '/pages/goods/detail') this.setPublicShare(); + if (this.goodsRoute != '/pages_goods/detail') this.setPublicShare(); // this.getBarrageData(); if (this.addonIsExist.form) { @@ -244,7 +244,7 @@ export default { }, goCart() { if (this.preview) return; // 开启预览,禁止任何操作和跳转 - this.$util.redirectTo('/pages/goods/cart'); + this.$util.redirectTo('/pages_goods/cart'); }, //-------------------------------------关注------------------------------------- //更新商品信息 diff --git a/common/js/lang.js b/common/js/lang.js index 6203dea..a0d4128 100644 --- a/common/js/lang.js +++ b/common/js/lang.js @@ -19,9 +19,36 @@ export default { var lang = require('../../lang/' + locale + '/common.js').lang; //当前页面语言包 - let route = _this.route.split("/"); - newRoute = route.slice(1, route.length); - let currentPageLang = require('../../lang/' + locale + '/' + newRoute.join("/") + '.js').lang; + let route = _this.route; + let routeParts = route.split("/"); + + // 映射新的页面目录到原来的语言文件目录 + if (routeParts[0] === 'pages_goods') { + routeParts[0] = 'goods'; + } else if (routeParts[0] === 'pages_order') { + routeParts[0] = 'order'; + } else if (routeParts[0] === 'pages_promotion' && routeParts[1] === 'point') { + // 处理积分相关的推广页面,映射到point语言文件目录 + routeParts = ['point', routeParts[2]]; + } else if (routeParts[0] === 'pages' && routeParts[1] === 'member') { + // 处理主包中的会员中心页面,映射到member目录 + routeParts = ['member', routeParts[2]]; + } else if (routeParts[0] === 'pages_tool') { + // 处理工具页面目录,根据子目录映射到对应的语言文件目录 + if (routeParts[1] === 'member') { + routeParts = ['member', routeParts[2]]; + } else if (routeParts[1] === 'order') { + routeParts = ['order', routeParts[2]]; + } else if (routeParts[1] === 'goods') { + routeParts = ['goods', routeParts[2]]; + } else if (routeParts[1] === 'help' || routeParts[1] === 'notice' || routeParts[1] === 'article') { + // 处理CMS相关页面 + routeParts = [routeParts[1], routeParts[2]]; + } + } + + let langPath = routeParts.join("/"); + let currentPageLang = require('../../lang/' + locale + '/' + langPath + '.js').lang; for (let f in currentPageLang) { lang[f] = currentPageLang[f]; @@ -29,15 +56,20 @@ export default { var arr = field.split("."); if (arr.length > 1) { - for (let i in arr) { - var next = parseInt(i) + 1; - if (next < arr.length) { - value = lang[arr[i]][arr[next]]; + // 处理嵌套属性,如 common.currencySymbol + let temp = lang; + let found = true; + for (let key of arr) { + if (temp[key] !== undefined) { + temp = temp[key]; + } else { + found = false; + break; } } - + value = found ? temp : field; } else { - value = lang[field]; + value = lang[field] !== undefined ? lang[field] : field; } } catch (e) { diff --git a/components/common-payment/common-payment.vue b/components/common-payment/common-payment.vue index 9c844e4..754c497 100644 --- a/components/common-payment/common-payment.vue +++ b/components/common-payment/common-payment.vue @@ -169,12 +169,12 @@ - + - {{ goodsItem.sku_name }} + {{ goodsItem.sku_name }} diff --git a/components/common-payment/payment.js b/components/common-payment/payment.js index eb91860..03b039d 100644 --- a/components/common-payment/payment.js +++ b/components/common-payment/payment.js @@ -922,7 +922,7 @@ export default { payClose() { // 更新购物车数量 this.$store.dispatch('getCartNumber'); - this.$util.redirectTo('/pages/order/detail', { + this.$util.redirectTo('/pages_order/detail', { order_id: this.$refs.choosePaymentPopup.payInfo.order_id }, 'redirectTo'); }, diff --git a/components/diy-components/diy-bottom-nav.vue b/components/diy-components/diy-bottom-nav.vue index 0103624..e20b045 100644 --- a/components/diy-components/diy-bottom-nav.vue +++ b/components/diy-components/diy-bottom-nav.vue @@ -4,7 +4,7 @@ - + @@ -15,7 +15,7 @@ {{ cartNumber > 99 ? '99+' : cartNumber }} diff --git a/components/diy-components/diy-category-item.vue b/components/diy-components/diy-category-item.vue index 2088a53..b8d1b0f 100644 --- a/components/diy-components/diy-category-item.vue +++ b/components/diy-components/diy-category-item.vue @@ -8,7 +8,7 @@ {{ category.category_name }} - + @@ -21,7 +21,7 @@ {{ one.category_name }} - + @@ -447,7 +447,7 @@ * @param {Object} item */ toDetail(item) { - this.$util.redirectTo('/pages/goods/detail', { + this.$util.redirectTo('/pages_goods/detail', { goods_id: item.goods_id }); }, diff --git a/components/diy-components/diy-category.vue b/components/diy-components/diy-category.vue index 9d1aae0..ee57887 100644 --- a/components/diy-components/diy-category.vue +++ b/components/diy-components/diy-category.vue @@ -5,7 +5,7 @@ - + - + @@ -23,9 +23,9 @@ - + - + @@ -118,7 +118,7 @@ - + 限时折扣 当前商品正在参加{{ item.promotion_name }} diff --git a/components/ns-goods-recommend/ns-goods-recommend.vue b/components/ns-goods-recommend/ns-goods-recommend.vue index 2bec54c..10a7d57 100644 --- a/components/ns-goods-recommend/ns-goods-recommend.vue +++ b/components/ns-goods-recommend/ns-goods-recommend.vue @@ -87,7 +87,7 @@ let data = { goods_id: e.goods_id }; - this.$util.redirectTo('/pages/goods/detail', data); + this.$util.redirectTo('/pages_goods/detail', data); }, getLikeList(size) { let that = this; diff --git a/components/ns-goods-sku/ns-goods-sku-index.vue b/components/ns-goods-sku/ns-goods-sku-index.vue index 5dcf5f0..4e632ca 100644 --- a/components/ns-goods-sku/ns-goods-sku-index.vue +++ b/components/ns-goods-sku/ns-goods-sku-index.vue @@ -34,7 +34,7 @@ return; } if (config == "detail" || data.is_virtual) { - this.$util.redirectTo('/pages/goods/detail', { + this.$util.redirectTo('/pages_goods/detail', { goods_id: data.goods_id }); return false; diff --git a/components/ns-goods-sku/ns-goods-sku.vue b/components/ns-goods-sku/ns-goods-sku.vue index 993553b..a7441d7 100644 --- a/components/ns-goods-sku/ns-goods-sku.vue +++ b/components/ns-goods-sku/ns-goods-sku.vue @@ -1109,7 +1109,7 @@ key: 'orderCreateData', data: data, success: () => { - this.$util.redirectTo('/pages/order/payment'); + this.$util.redirectTo('/pages_order/payment'); this.btnSwitch = false; } }); diff --git a/pages.json b/pages.json index de4f2f0..2a46ab0 100644 --- a/pages.json +++ b/pages.json @@ -1,5 +1,6 @@ { - "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages + "pages": [ + // pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages { "path": "pages/index/index", "style": { @@ -7,7 +8,6 @@ "enablePullDownRefresh": true } }, - { "path": "pages/contact/contact", "style": { @@ -15,15 +15,6 @@ } }, //******************商品模块(11)****************** - { - "path": "pages/goods/cart", - "style": { - // #ifdef APP-PLUS - "navigationStyle": "custom", - // #endif - "navigationBarTitleText": "购物车" - } - }, { "path": "pages/goods/category", "style": { @@ -32,93 +23,110 @@ "enablePullDownRefresh": true } }, - - // 商品详情 - { - "path": "pages/goods/detail", - "style": { - "navigationBarTitleText": "商品详情" - } - }, - { - "path": "pages/goods/list", - "style": { - // #ifdef APP-PLUS - "navigationStyle": "custom", - // #endif - "navigationBarTitleText": "商品列表" - } - }, - //******************会员模块(20)****************** { "path": "pages/member/index", "style": { "enablePullDownRefresh": true } - }, - //******************订单模块(12)****************** - { - "path": "pages/order/payment", - "style": { - "navigationStyle": "custom" - } - }, - { - "path": "pages/order/list", - "style": { - // #ifdef APP-PLUS - "navigationStyle": "custom" - // #endif - } - }, - { - "path": "pages/order/detail", - "style": { - // #ifdef APP-PLUS - "navigationStyle": "custom" - // #endif - } - }, - { - "path": "pages/order/detail_local_delivery", - "style": { - // #ifdef APP-PLUS - "navigationStyle": "custom" - // #endif - } - }, - { - "path": "pages/order/detail_pickup", - "style": { - // #ifdef APP-PLUS - "navigationStyle": "custom" - // #endif - } - }, - //积分订单详情 - { - "path": "pages/order/detail_point", - "style": { - // #ifdef APP-PLUS - "navigationStyle": "custom" - // #endif - } } ], - "subPackages": [{ - + "subPackages": [ + { + //******************商品模块分包****************** + "root": "pages_goods", + "pages": [ + { + "path": "cart", + "style": { + // #ifdef APP-PLUS + "navigationStyle": "custom", + // #endif + "navigationBarTitleText": "购物车" + } + }, + { + "path": "detail", + "style": { + "navigationBarTitleText": "商品详情" + } + }, + { + "path": "list", + "style": { + // #ifdef APP-PLUS + "navigationStyle": "custom", + // #endif + "navigationBarTitleText": "商品列表" + } + } + ] + }, + { + //******************订单模块分包****************** + "root": "pages_order", + "pages": [ + { + "path": "payment", + "style": { + "navigationStyle": "custom" + } + }, + { + "path": "list", + "style": { + // #ifdef APP-PLUS + "navigationStyle": "custom" + // #endif + } + }, + { + "path": "detail", + "style": { + // #ifdef APP-PLUS + "navigationStyle": "custom" + // #endif + } + }, + { + "path": "detail_local_delivery", + "style": { + // #ifdef APP-PLUS + "navigationStyle": "custom" + // #endif + } + }, + { + "path": "detail_pickup", + "style": { + // #ifdef APP-PLUS + "navigationStyle": "custom" + // #endif + } + }, + //积分订单详情 + { + "path": "detail_point", + "style": { + // #ifdef APP-PLUS + "navigationStyle": "custom" + // #endif + } + } + ] + }, + { //******************营销活动模块(26)****************** "root": "pages_promotion", "pages": [ - //----------积分模块(2)---------- { "path": "point/list", "style": { "navigationStyle": "custom" } - }, { + }, + { "path": "point/goods_list", "style": { // #ifdef APP-PLUS @@ -156,7 +164,6 @@ // #endif } }, - //****************** 商户 ****************** { "path": "merch/merchcategory", @@ -337,7 +344,7 @@ "path": "index/diy", "style": { // #ifdef MP-WEIXIN - // "navigationStyle": "custom", + // "navigationStyle": "custom", // #endif "enablePullDownRefresh": true } @@ -581,7 +588,6 @@ // #endif } }, - //******************商品模块****************** { "path": "goods/coupon", @@ -631,8 +637,6 @@ // #endif } }, - - //******************CMS模块(6)****************** { "path": "help/list", @@ -869,7 +873,7 @@ // #endif "navigationBarTitleText": "介质材料搜索" } - }, + }, { "path": "seal/medium/detail", "style": { @@ -918,7 +922,8 @@ "selectedColor": "#FF0036", "backgroundColor": "#fff", "borderStyle": "white", - "list": [{ + "list": [ + { "pagePath": "pages/index/index", "text": "" }, @@ -942,7 +947,9 @@ "preloadRule": { "pages/index/index": { "network": "all", - "packages": ["pages_tool"] + "packages": [ + "pages_tool" + ] } } } \ No newline at end of file diff --git a/pages/goods/cart.vue b/pages_goods/cart.vue similarity index 100% rename from pages/goods/cart.vue rename to pages_goods/cart.vue diff --git a/pages/goods/detail.vue b/pages_goods/detail.vue similarity index 99% rename from pages/goods/detail.vue rename to pages_goods/detail.vue index f970686..6465285 100644 --- a/pages/goods/detail.vue +++ b/pages_goods/detail.vue @@ -140,7 +140,7 @@ diff --git a/pages/goods/list.vue b/pages_goods/list.vue similarity index 100% rename from pages/goods/list.vue rename to pages_goods/list.vue diff --git a/pages/goods/public/css/cart.scss b/pages_goods/public/css/cart.scss similarity index 100% rename from pages/goods/public/css/cart.scss rename to pages_goods/public/css/cart.scss diff --git a/pages/goods/public/css/detail.scss b/pages_goods/public/css/detail.scss similarity index 100% rename from pages/goods/public/css/detail.scss rename to pages_goods/public/css/detail.scss diff --git a/pages/goods/public/css/list.scss b/pages_goods/public/css/list.scss similarity index 100% rename from pages/goods/public/css/list.scss rename to pages_goods/public/css/list.scss diff --git a/pages/goods/public/js/cart.js b/pages_goods/public/js/cart.js similarity index 99% rename from pages/goods/public/js/cart.js rename to pages_goods/public/js/cart.js index a9fbaf2..5c2f9ab 100644 --- a/pages/goods/public/js/cart.js +++ b/pages_goods/public/js/cart.js @@ -367,7 +367,7 @@ export default { cart_ids: cart_ids.toString() }, success: () => { - this.$util.redirectTo('/pages/order/payment'); + this.$util.redirectTo('/pages_order/payment'); this.isSub = false; } }); @@ -413,7 +413,7 @@ export default { this.$forceUpdate(); }, toGoodsDetail(item) { - this.$util.redirectTo('/pages/goods/detail', { + this.$util.redirectTo('/pages_goods/detail', { sku_id: item.sku_id }); }, diff --git a/pages/goods/public/js/detail.js b/pages_goods/public/js/detail.js similarity index 99% rename from pages/goods/public/js/detail.js rename to pages_goods/public/js/detail.js index f010ccb..787a955 100644 --- a/pages/goods/public/js/detail.js +++ b/pages_goods/public/js/detail.js @@ -1,7 +1,7 @@ export default { data() { return { - goodsRoute: '/pages/goods/detail', + goodsRoute: '/pages_goods/detail', couponList: [], //优惠券列表 couponBtnSwitch: false, //获取优惠券防止重复提交 diff --git a/pages/goods/public/js/list.js b/pages_goods/public/js/list.js similarity index 99% rename from pages/goods/public/js/list.js rename to pages_goods/public/js/list.js index e861076..e4ee7ff 100644 --- a/pages/goods/public/js/list.js +++ b/pages_goods/public/js/list.js @@ -305,7 +305,7 @@ export default { }, //商品详情 toDetail(item) { - this.$util.redirectTo('/pages/goods/detail', { + this.$util.redirectTo('/pages_goods/detail', { goods_id: item.goods_id }); }, diff --git a/pages/order/detail.vue b/pages_order/detail.vue similarity index 99% rename from pages/order/detail.vue rename to pages_order/detail.vue index ec9f273..47422db 100644 --- a/pages/order/detail.vue +++ b/pages_order/detail.vue @@ -654,13 +654,13 @@ this.getOrderData(); } else { this.$util.redirectTo('/pages_tool/login/login', { - back: '/pages/order/detail?order_id=' + this.orderId + '&merchant_trade_no=' + this.merchantTradeNo + back: '/pages_order/detail?order_id=' + this.orderId + '&merchant_trade_no=' + this.merchantTradeNo }); } }, methods: { goDetail(e) { - this.$util.redirectTo('/pages/goods/detail', { + this.$util.redirectTo('/pages_goods/detail', { goods_id: e.goods_id }); }, @@ -721,7 +721,7 @@ title: '未获取到订单信息!' }); setTimeout(() => { - this.$util.redirectTo('/pages/order/list'); + this.$util.redirectTo('/pages_order/list'); }, 1500); } }, diff --git a/pages/order/detail_local_delivery.vue b/pages_order/detail_local_delivery.vue similarity index 83% rename from pages/order/detail_local_delivery.vue rename to pages_order/detail_local_delivery.vue index 005f434..9a56aa7 100644 --- a/pages/order/detail_local_delivery.vue +++ b/pages_order/detail_local_delivery.vue @@ -12,7 +12,7 @@ export default { }, onLoad(option) { if (option.order_id) { - this.$util.redirectTo('/pages/order/detail', {order_id: option.order_id}, 'redirectTo'); + this.$util.redirectTo('/pages_order/detail', {order_id: option.order_id}, 'redirectTo'); } } }; diff --git a/pages/order/detail_pickup.vue b/pages_order/detail_pickup.vue similarity index 83% rename from pages/order/detail_pickup.vue rename to pages_order/detail_pickup.vue index 005f434..9a56aa7 100644 --- a/pages/order/detail_pickup.vue +++ b/pages_order/detail_pickup.vue @@ -12,7 +12,7 @@ export default { }, onLoad(option) { if (option.order_id) { - this.$util.redirectTo('/pages/order/detail', {order_id: option.order_id}, 'redirectTo'); + this.$util.redirectTo('/pages_order/detail', {order_id: option.order_id}, 'redirectTo'); } } }; diff --git a/pages/order/detail_point.vue b/pages_order/detail_point.vue similarity index 98% rename from pages/order/detail_point.vue rename to pages_order/detail_point.vue index 75b21f1..471704f 100644 --- a/pages/order/detail_point.vue +++ b/pages_order/detail_point.vue @@ -164,7 +164,7 @@ this.getOrderData(); } else { this.$util.redirectTo('/pages_tool/login/login', { - back: '/pages/order/detail_point?order_id=' + this.orderId + back: '/pages_order/detail_point?order_id=' + this.orderId }); } }, @@ -205,7 +205,7 @@ title: '未获取到订单信息!' }); setTimeout(() => { - this.$util.redirectTo('/pages/order/list'); + this.$util.redirectTo('/pages_order/list'); }, 1500); } }, diff --git a/pages/order/list.vue b/pages_order/list.vue similarity index 97% rename from pages/order/list.vue rename to pages_order/list.vue index db0ca2f..7dcf0ce 100644 --- a/pages/order/list.vue +++ b/pages_order/list.vue @@ -3,8 +3,8 @@ - - + + @@ -192,7 +192,7 @@ if (this.$refs.mescroll) this.$refs.mescroll.refresh(); } else { this.$nextTick(() => { - this.$refs.login.open('/pages/order/list?status=' + this.orderStatus); + this.$refs.login.open('/pages_order/list?status=' + this.orderStatus); }) } }, @@ -345,13 +345,13 @@ switch (parseInt(data.order_type)) { case 2: // 自提订单 - this.$util.redirectTo('/pages/order/detail_pickup', { + this.$util.redirectTo('/pages_order/detail_pickup', { order_id: data.order_id }); break; case 3: // 本地配送订单 - this.$util.redirectTo('/pages/order/detail_local_delivery', { + this.$util.redirectTo('/pages_order/detail_local_delivery', { order_id: data.order_id }); break; @@ -362,7 +362,7 @@ }); break; default: - this.$util.redirectTo('/pages/order/detail', { + this.$util.redirectTo('/pages_order/detail', { order_id: data.order_id }); break; diff --git a/pages/order/payment.vue b/pages_order/payment.vue similarity index 100% rename from pages/order/payment.vue rename to pages_order/payment.vue diff --git a/pages/order/public/css/detail.scss b/pages_order/public/css/detail.scss similarity index 100% rename from pages/order/public/css/detail.scss rename to pages_order/public/css/detail.scss diff --git a/pages/order/public/css/list.scss b/pages_order/public/css/list.scss similarity index 100% rename from pages/order/public/css/list.scss rename to pages_order/public/css/list.scss diff --git a/pages/order/public/js/orderMethod.js b/pages_order/public/js/orderMethod.js similarity index 100% rename from pages/order/public/js/orderMethod.js rename to pages_order/public/js/orderMethod.js diff --git a/pages/order/public/js/refundMethod.js b/pages_order/public/js/refundMethod.js similarity index 100% rename from pages/order/public/js/refundMethod.js rename to pages_order/public/js/refundMethod.js diff --git a/pages_promotion/fenxiao/apply.vue b/pages_promotion/fenxiao/apply.vue index f7dc267..f326efd 100644 --- a/pages_promotion/fenxiao/apply.vue +++ b/pages_promotion/fenxiao/apply.vue @@ -253,7 +253,7 @@ }, //商品详情 toDetail(item) { - this.$util.redirectTo('/pages/goods/detail', { + this.$util.redirectTo('/pages_goods/detail', { goods_id: item.goods_id }); }, diff --git a/pages_promotion/fenxiao/public/js/goods_list.js b/pages_promotion/fenxiao/public/js/goods_list.js index 7d68c2d..67b8f53 100644 --- a/pages_promotion/fenxiao/public/js/goods_list.js +++ b/pages_promotion/fenxiao/public/js/goods_list.js @@ -1,265 +1,265 @@ -import { - Weixin -} from '@/common/js/wx-jssdk.js'; - -export default { - data() { - return { - categoryList: [], - goodsList: [], - categoryId: 0, - is_fenxiao: false, - currIndex: 0, - poster: '-1', //海报 - posterMsg: '', //海报错误信息 - shareUrl: '/pages_promotion/fenxiao/goods_list', - shareType: 'goods', - //海报模板id - templateId: ['default'], - } - }, - onLoad(options) { - setTimeout(() => { - if (!this.addonIsExist.fenxiao) { - this.$util.showToast({ - title: '商家未开启分销', - mask: true, - duration: 2000 - }); - setTimeout(() => { - this.$util.redirectTo('/pages/index/index'); - }, 2000); - } - }, 1000); - if (options.templateId) { - this.templateId = options.templateId.split(','); - } - this.getGoodsCategoryTree(); - }, - onShow() { - - if (!this.storeToken) { - this.$util.redirectTo( - '/pages_tool/login/login', { - back: '/pages_promotion/fenxiao/goods_list' - }, - 'redirectTo' - ); - return; - } - - if (this.fenxiaoWords && this.fenxiaoWords.concept) this.$langConfig.title(this.fenxiaoWords.concept + '中心'); - this.is_fenxiao = Boolean(this.memberInfo.is_fenxiao); - }, - methods: { - //获取列表 - getGoodsList(mescroll) { - this.$api.sendRequest({ - url: '/fenxiao/api/goods/page', - data: { - page: mescroll.num, - page_size: mescroll.size, - category_id: this.categoryId - }, - success: res => { - let newArr = [] - let msg = res.message; - if (res.code == 0 && res.data) { - newArr = res.data.list; - } else { - this.$util.showToast({ - title: msg - }) - } - mescroll.endSuccess(newArr.length); - //设置列表数据 - if (mescroll.num == 1) this.goodsList = []; //如果是第一页需手动制空列表 - this.goodsList = this.goodsList.concat(newArr); //追加新数据 - if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); - }, - fail: res => { - //联网失败的回调 - mescroll.endErr(); - if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); - } - }); - }, - //商品详情 - navToDetailPage(item) { - this.$util.redirectTo('/pages/goods/detail', { - goods_id: item.goods_id - }); - }, - //查询一级商品分类 - getGoodsCategoryTree() { - this.$api.sendRequest({ - url: '/api/goodscategory/tree', - data: { - level: 1 - }, - success: res => { - if (res.code == 0) { - this.categoryList = res.data; - } - } - }); - }, - changeCategory(category_id) { - this.categoryId = category_id; - if (this.$refs.mescroll) { - this.$refs.mescroll.refresh(); - this.$refs.mescroll.myScrollTo(0); - } - }, - // 分享商品 - shareFn(type, keys) { - this.shareType = type; - if (this.shareType == "fenxiao") - this.openPosterPopup(); - else { - this.currIndex = keys; - this.$refs.sharePopup.open(); - } - }, - // #ifdef MP-WEIXIN - /** - * 将商品推荐到微信圈子 - */ - openBusinessView() { - if (wx.openBusinessView) { - wx.openBusinessView({ - businessType: 'friendGoodsRecommend', - extraData: { - product: { - item_code: this.goodsList[this.currIndex].goods_id, - title: this.goodsList[this.currIndex].sku_name, - image_list: this.$util.img(this.goodsList[this.currIndex].goods_image) - } - }, - success: function (res) { - console.log('success', res); - }, - fail: function (res) { - console.log('fail', res); - } - }) - } - }, - // #endif - //-------------------------------------海报------------------------------------- - // 打开海报弹出层 - openPosterPopup() { - this.getGoodsPoster(); - this.$refs.sharePopup.close(); - }, - // 关闭海报弹出层 - closePosterPopup() { - this.$refs.posterPopup.close(); - }, - //生成海报 - getGoodsPoster() { - uni.showLoading({ - 'title': '海报生成中...' - }); - let url = ""; - let data = {}; - if (this.shareType == "goods") { - url = "/api/goods/poster"; - data.page = "/pages/goods/detail"; - data.qrcode_param = JSON.stringify({ - goods_id: this.goodsList[this.currIndex].goods_id, - source_member: this.memberInfo.member_id - }); - } else { - url = "/fenxiao/api/fenxiao/poster"; - data.page = "/pages/index/index"; - data.qrcode_param = JSON.stringify({}); - data.template_id = this.templateId[0]; - } - - this.$api.sendRequest({ - url: url, - data: data, - success: res => { - if (res.code == 0) { - this.poster = res.data.path + "?time=" + new Date().getTime(); - this.$refs.posterPopup.open(); - } else { - this.posterMsg = res.message; - } - uni.hideLoading(); - }, - fail: err => { - uni.hideLoading(); - } - }); - }, - // #ifdef MP || APP-PLUS - //小程序中保存海报 - saveGoodsPoster() { - let url = this.$util.img(this.poster); - uni.downloadFile({ - url: url, - success: (res) => { - if (res.statusCode === 200) { - uni.saveImageToPhotosAlbum({ - filePath: res.tempFilePath, - success: () => { - this.$util.showToast({ - title: "保存成功" - }); - }, - fail: () => { - this.$util.showToast({ - title: "保存失败,请稍后重试" - }); - } - }); - } - } - }); - }, - // #endif - // 打开分享弹出层 - openSharePopup() { - this.$refs.sharePopup.open(); - }, - // 关闭分享弹出层 - closeSharePopup() { - this.$refs.sharePopup.close(); - }, - copyUrl() { - let text = this.$config.h5Domain + '/pages/goods/detail?goods_id=' + this.goodsList[this.currIndex].goods_id + '&source_member=' + this.memberInfo.member_id; - this.$util.copy(text, () => { - this.closeSharePopup(); - }); - }, - imageError(index) { - this.goodsList[index].sku_image = this.$util.getDefaultImage().goods; - this.$forceUpdate(); - } - }, - /** - * 自定义分享内容 - * @param {Object} res - */ - onShareAppMessage(res) { - var path = this.shareUrl; - - if (this.shareType == "goods") { - path = `/pages/goods/detail?goods_id=${this.goodsList[this.currIndex].goods_id}&sku_id=${this.goodsList[this.currIndex].sku_id}&source_member=${this.memberInfo.member_id}`; - } - - return { - title: this.goodsList[this.currIndex].sku_name, - imageUrl: this.$util.img(this.goodsList[this.currIndex].goods_image, { - size: 'big' - }), - path: path, - success: res => { - }, - fail: res => { - } - }; - } +import { + Weixin +} from '@/common/js/wx-jssdk.js'; + +export default { + data() { + return { + categoryList: [], + goodsList: [], + categoryId: 0, + is_fenxiao: false, + currIndex: 0, + poster: '-1', //海报 + posterMsg: '', //海报错误信息 + shareUrl: '/pages_promotion/fenxiao/goods_list', + shareType: 'goods', + //海报模板id + templateId: ['default'], + } + }, + onLoad(options) { + setTimeout(() => { + if (!this.addonIsExist.fenxiao) { + this.$util.showToast({ + title: '商家未开启分销', + mask: true, + duration: 2000 + }); + setTimeout(() => { + this.$util.redirectTo('/pages/index/index'); + }, 2000); + } + }, 1000); + if (options.templateId) { + this.templateId = options.templateId.split(','); + } + this.getGoodsCategoryTree(); + }, + onShow() { + + if (!this.storeToken) { + this.$util.redirectTo( + '/pages_tool/login/login', { + back: '/pages_promotion/fenxiao/goods_list' + }, + 'redirectTo' + ); + return; + } + + if (this.fenxiaoWords && this.fenxiaoWords.concept) this.$langConfig.title(this.fenxiaoWords.concept + '中心'); + this.is_fenxiao = Boolean(this.memberInfo.is_fenxiao); + }, + methods: { + //获取列表 + getGoodsList(mescroll) { + this.$api.sendRequest({ + url: '/fenxiao/api/goods/page', + data: { + page: mescroll.num, + page_size: mescroll.size, + category_id: this.categoryId + }, + success: res => { + let newArr = [] + let msg = res.message; + if (res.code == 0 && res.data) { + newArr = res.data.list; + } else { + this.$util.showToast({ + title: msg + }) + } + mescroll.endSuccess(newArr.length); + //设置列表数据 + if (mescroll.num == 1) this.goodsList = []; //如果是第一页需手动制空列表 + this.goodsList = this.goodsList.concat(newArr); //追加新数据 + if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); + }, + fail: res => { + //联网失败的回调 + mescroll.endErr(); + if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); + } + }); + }, + //商品详情 + navToDetailPage(item) { + this.$util.redirectTo('/pages_goods/detail', { + goods_id: item.goods_id + }); + }, + //查询一级商品分类 + getGoodsCategoryTree() { + this.$api.sendRequest({ + url: '/api/goodscategory/tree', + data: { + level: 1 + }, + success: res => { + if (res.code == 0) { + this.categoryList = res.data; + } + } + }); + }, + changeCategory(category_id) { + this.categoryId = category_id; + if (this.$refs.mescroll) { + this.$refs.mescroll.refresh(); + this.$refs.mescroll.myScrollTo(0); + } + }, + // 分享商品 + shareFn(type, keys) { + this.shareType = type; + if (this.shareType == "fenxiao") + this.openPosterPopup(); + else { + this.currIndex = keys; + this.$refs.sharePopup.open(); + } + }, + // #ifdef MP-WEIXIN + /** + * 将商品推荐到微信圈子 + */ + openBusinessView() { + if (wx.openBusinessView) { + wx.openBusinessView({ + businessType: 'friendGoodsRecommend', + extraData: { + product: { + item_code: this.goodsList[this.currIndex].goods_id, + title: this.goodsList[this.currIndex].sku_name, + image_list: this.$util.img(this.goodsList[this.currIndex].goods_image) + } + }, + success: function (res) { + console.log('success', res); + }, + fail: function (res) { + console.log('fail', res); + } + }) + } + }, + // #endif + //-------------------------------------海报------------------------------------- + // 打开海报弹出层 + openPosterPopup() { + this.getGoodsPoster(); + this.$refs.sharePopup.close(); + }, + // 关闭海报弹出层 + closePosterPopup() { + this.$refs.posterPopup.close(); + }, + //生成海报 + getGoodsPoster() { + uni.showLoading({ + 'title': '海报生成中...' + }); + let url = ""; + let data = {}; + if (this.shareType == "goods") { + url = "/api/goods/poster"; + data.page = "/pages_goods/detail"; + data.qrcode_param = JSON.stringify({ + goods_id: this.goodsList[this.currIndex].goods_id, + source_member: this.memberInfo.member_id + }); + } else { + url = "/fenxiao/api/fenxiao/poster"; + data.page = "/pages/index/index"; + data.qrcode_param = JSON.stringify({}); + data.template_id = this.templateId[0]; + } + + this.$api.sendRequest({ + url: url, + data: data, + success: res => { + if (res.code == 0) { + this.poster = res.data.path + "?time=" + new Date().getTime(); + this.$refs.posterPopup.open(); + } else { + this.posterMsg = res.message; + } + uni.hideLoading(); + }, + fail: err => { + uni.hideLoading(); + } + }); + }, + // #ifdef MP || APP-PLUS + //小程序中保存海报 + saveGoodsPoster() { + let url = this.$util.img(this.poster); + uni.downloadFile({ + url: url, + success: (res) => { + if (res.statusCode === 200) { + uni.saveImageToPhotosAlbum({ + filePath: res.tempFilePath, + success: () => { + this.$util.showToast({ + title: "保存成功" + }); + }, + fail: () => { + this.$util.showToast({ + title: "保存失败,请稍后重试" + }); + } + }); + } + } + }); + }, + // #endif + // 打开分享弹出层 + openSharePopup() { + this.$refs.sharePopup.open(); + }, + // 关闭分享弹出层 + closeSharePopup() { + this.$refs.sharePopup.close(); + }, + copyUrl() { + let text = this.$config.h5Domain + '/pages_goods/detail?goods_id=' + this.goodsList[this.currIndex].goods_id + '&source_member=' + this.memberInfo.member_id; + this.$util.copy(text, () => { + this.closeSharePopup(); + }); + }, + imageError(index) { + this.goodsList[index].sku_image = this.$util.getDefaultImage().goods; + this.$forceUpdate(); + } + }, + /** + * 自定义分享内容 + * @param {Object} res + */ + onShareAppMessage(res) { + var path = this.shareUrl; + + if (this.shareType == "goods") { + path = `/pages_goods/detail?goods_id=${this.goodsList[this.currIndex].goods_id}&sku_id=${this.goodsList[this.currIndex].sku_id}&source_member=${this.memberInfo.member_id}`; + } + + return { + title: this.goodsList[this.currIndex].sku_name, + imageUrl: this.$util.img(this.goodsList[this.currIndex].goods_image, { + size: 'big' + }), + path: path, + success: res => { + }, + fail: res => { + } + }; + } } \ No newline at end of file diff --git a/pages_promotion/merch/public/edit.js b/pages_promotion/merch/public/edit.js index a4a4817..f115d2a 100644 --- a/pages_promotion/merch/public/edit.js +++ b/pages_promotion/merch/public/edit.js @@ -1,952 +1,952 @@ -// import {getGoodsInfoById,getCategoryTree,addGoods,editGoods,addVirtualGoods,editVirtualGoods,addVirtualCardGoods,editVirtualCardGoods} from '@/api/goods' -// import {getOrderFormList} from '@/api/form' -// import {getSupplyList} from '@/api/supply' -export default { - data() { - return { - repeatFlag: false, - isIphoneX: false, - goodsImgHeight: 165, // 商品图片高度 - isAWait: false, - albumPage: 'goodsEdit', - //店内分类 - shopCategoryNumber: 1, - shopCategoryData: { - store_0: {} - }, - shopCategoryIndex: '', - - categoryList: [], - secondCategory: [], - thirdCategory: [], - categoryId: [0, 0, 0], - categoryName: ['', '', ''], - currentLevel: 1, - lastLevel: 1, - showFisrt: true, - showSecond: false, - showThird: false, - - goodsData: { - id: 0,//商品id - goodsname:'',//商品名称 - subtitle:'',//商品简介 - is_show_arrive:1,//默认商品预达简介0关闭1开启 - diy_arrive_switch:0,//商品自定义预达简介0关闭1开启 - goods_start_count:1,//起售数量 - grounding:1,//0下架1上架 - is_index_show:1,//0首页不推荐1推荐 - price:0,//售价 - productprice:0,//原价 - costprice:0,//成本价 - total:0,//库存 - pick_up_type:0,//提货时,0当日达1次日达2隔日达3自定义 - dispatchtype:1,//1统一运费 - dispatchprice:0,//统一运费金额 - begin_time:'',//团购开始时间 - end_time:'',//团购结束时间 - oneday_limit_count:0,//每天限购 - one_limit_count:0,//单次限购 - total_limit_count:0,//历史限购 - is_all_sale:0,//所有团长1部分团长0 - goods_image:[], - begin_time:'',//团购开始时间 - end_time:''//团购结束时间 - }, - groundingArray: ['下架', '上架'], - - pickuptypeArray: ['当日达', '次日达', '隔日达'],//, '自定义' - - - currCategory: 0, // 当前所设置的商品分类 - virtualDeliverArray: [{ - name: '自动发货', - value: 'auto_deliver', - }, - { - name: '手动发货', - value: 'artificial_deliver', - }, - { - name: '到店核销', - value: 'verify', - } - ], - virtualDeliverValue: { - 'auto_deliver': '自动发货', - 'artificial_deliver': '手动发货', - 'verify': '到店核销' - }, - virtualReceiveArray: [{ - name: '自动收货', - value: 'auto_receive', - }, - { - name: '买家确认收货', - value: 'artificial_receive', - }, - ], - virtualReceiveValue: { - 'auto_receive': '自动收货', - 'artificial_receive': '买家确认收货', - }, - validityTypeArray: ['永久', '购买后几日有效', '指定过期日期'], - virtualIndate: 0, - minDate: '', - carmiLength: '添加卡密', - limitLength: [ //限购 - { - name: '单次限购', - value: '1' - }, - { - name: '长期限购', - value: '2' - } - ], - current: 0, - goodsFormArray: [], - goodsForm: [], - - supplyFormArray: [], - supplyForm: [] - }; - }, - async onLoad(option) { - this.goodsData.id = option.id || 0; - - // if (!this.$util.checkToken('/pages/goods/edit/index?id=' + this.goodsData.id)) return; - - // this.clearStoreage(); - - // this.getCategoryTreeFn(); - if (this.goodsData.id) { - this.isAWait = true; - uni.setNavigationBarTitle({ - title: '编辑商品' - }); - await this.editGetGoodsInfo(); - } else { - - this.isAWait = false; - uni.setNavigationBarTitle({ - title: '添加商品' - }); - } - - let date = new Date(); - this.minDate = date.getFullYear() + '-' + date.getMonth() + '-' + date.getUTCDate(); - - // if (this.addonIsExit.form) this.getGoodsForm(); - - // if (this.addonIsExit.supply) this.getSupplyList(); - - }, - onShow() { - this.isIphoneX = this.$util.uniappIsIPhoneX(); - //this.refreshData(); - }, - methods: { - - groundingChange(e) { - this.goodsData.grounding = e.detail.value; - }, - - pickuptypeChange(e) { - this.goodsData.pick_up_type = e.detail.value; - }, - - // 获取编辑商品数据 - async editGetGoodsInfo() { - this.$api.sendRequest({ - url: 'app.getgoodsinfo', - data:{ - id:this.goodsData.id - }, - success: res => { - console.log(res) - if(res.result.detail){ - this.goodsData = res.result.detail - console.log(this.goodsData.goods_image) - }else{ - this.$util.showToast({ - title: '商品不存在', - }); - setTimeout(() => { - this.$util.redirectTo('/pages/goods/list', {}, 'redirectTo'); - }, 1000); - } - // if (res.status == 0) { - // setTimeout(() => { - // this.$util.redirectTo('/pages/goods/list', {}, 'redirectTo'); - // }, 1000); - // } - } - }) - /*var res = await getGoodsInfoById(this.goodsData.goods_id); - if (res.code == 0 && res.data) { - var data = res.data; - - data.goods_category.forEach((item, index) => { - this.shopCategoryData['store_' + index] = { - category_id: item.id, - category_name: item.category_name - } - }) - this.shopCategoryNumber = data.goods_category.length; - - // 商品分类 - data.category_id = data.goods_category[0].id; - data.category_name = data.goods_category[0].category_name.replace(/\//g, " / "); - - if (typeof data.category_id == 'string') { - this.categoryId = data.category_id.split(","); - this.categoryName = data.category_name.split(" / "); - } else { - this.categoryId = data.category_id; - this.categoryName = data.category_name; - } - - delete data.category_json; - delete data.goods_category; - - data.goods_image = data.goods_image.split(","); - - data.goods_sku_data.forEach((item) => { - if (item.sku_spec_format) item.sku_spec_format = JSON.parse(item.sku_spec_format); - }); - - if (data.goods_spec_format) { - uni.setStorageSync("editGoodsSpecFormat", data.goods_spec_format); - uni.setStorageSync("editGoodsSkuData", JSON.stringify(data.goods_sku_data)); - data.goods_spec_format = JSON.parse(data.goods_spec_format); - } else { - data.sku_id = data.goods_sku_data[0].sku_id; - data.price = data.goods_sku_data[0].price; - data.market_price = data.goods_sku_data[0].market_price; - data.cost_price = data.goods_sku_data[0].cost_price; - data.weight = data.goods_sku_data[0].weight; - data.volume = data.goods_sku_data[0].volume; - data.sku_no = data.goods_sku_data[0].sku_no; - } - - if (data.goods_class == 1) { - // 实物商品 - delete data.virtual_indate; - uni.setStorageSync("editGoodsShippingTemplateId", data.shipping_template); - uni.setStorageSync("editGoodsShippingTemplateName", data.template_name ? data.template_name : ''); - } else { - // 虚拟商品 - delete data.shipping_template; - delete data.is_free_shipping; - } - - // 商品参数 - if (data.goods_attr_format) { - uni.setStorageSync("editGoodsAttrClass", data.goods_attr_class); - uni.setStorageSync("editGoodsAttrName", data.goods_attr_name); - uni.setStorageSync("editGoodsAttrFormat", data.goods_attr_format); - data.goods_attr_format = JSON.parse(data.goods_attr_format); - } - - uni.setStorageSync("editGoodsState", data.goods_state); - uni.setStorageSync("editGoodsContent", data.goods_content); - - if (data.verify_validity_type == 1) { - this.virtualIndate = data.virtual_indate; - } else if (data.verify_validity_type == 2) { - this.virtualTime = this.$util.timeStampTurnTime(data.virtual_indate, 'Y-m-d'); - } - data.verify_num = data.goods_sku_data[0].verify_num - - this.goodsData = data; - - this.goodsData.goods_form_index = 0; - - this.goodsData.supply_index = 0; - - this.$forceUpdate(); - } else { - this.$util.showToast({ - title: '商品不存在', - }); - setTimeout(() => { - this.$util.redirectTo('/pages/goods/list', {}, 'redirectTo'); - }, 1000); - }*/ - }, - // 选择商品分类 - openGoodsCategoryPop(index) { - this.currCategory = index; - if (this.shopCategoryData['store_' + index].category_id) { - this.categoryId = this.shopCategoryData['store_' + index].category_id.split(','); - this.categoryName = this.shopCategoryData['store_' + index].category_name.split(' / '); - - this.categoryList.forEach((item, index) => { - item.selected = this.categoryId.indexOf(item.category_id.toString()) != -1; - if (item.selected) { - this.secondCategory = item.child_list; - } - if (item.child_list) { - if (item.selected) this.lastLevel = 2; - item.child_list.forEach(secondItem => { - secondItem.selected = this.categoryId.indexOf(secondItem.category_id.toString()) != -1; - if (secondItem.selected) { - this.thirdCategory = secondItem.child_list; - } - }); - } - }); - this.changeShow(this.categoryId.length); - } else { - this.categoryId = [0]; - this.categoryName = ['']; - this.changeShow(1); - } - this.$refs.categoryPopup.open(); - }, - closeGoodsCategoryPop() { - this.$refs.categoryPopup.close(); - }, - // 编辑规格类型 - openGoodsSpec() { - this.$util.redirectTo('/pages/goods/edit/spec'); - }, - // 编辑多规格 - openGoodsSpecEdit() { - this.$util.redirectTo('/pages/goods/edit/spec_edit', { - goods_class: this.goodsData.goods_class, - virtual_deliver_type: this.goodsData.virtual_deliver_type - }); - }, - //编辑卡密 - openCarmichaelEdit() { - this.$util.redirectTo('/pages/goods/edit/carmichael_edit', { - goods_class: this.goodsData.goods_class - }); - }, - // 编辑商品状态 - openGoodsState() { - this.$util.redirectTo('/pages/goods/edit/state', { - goods_state: this.goodsData.goods_state - }); - }, - // 编辑快递运费 - openExpressFreight() { - this.$util.redirectTo('/pages/goods/edit/express_freight', { - template_id: this.goodsData.shipping_template - }); - }, - // 编辑商品详情 - openGoodsContent() { - this.$util.redirectTo('/pages/goods/edit/content'); - }, - // 编辑商品参数 - openAttr() { - this.$util.redirectTo('/pages/goods/edit/attr'); - }, - /** - * 刷新商品图片高度 - * @param {Object} data - */ - refreshGoodsImgHeight(data) { - if (data.height == '') return; - var height = parseFloat(data.height.replace('px', '')); - this.goodsImgHeight = height + 80; - this.$forceUpdate(); - if (data.isLoad && this.$refs.loadingCover) { - // 数据渲染留点时间 - setTimeout(() => { - this.$refs.loadingCover.hide(); - }, 100); - } - uni.removeStorageSync("selectedAlbumImg"); - - }, - // 获取商品分类树状结构 - getCategoryTreeFn() { - getCategoryTree().then(res=>{ - if (res.data) { - this.categoryList = res.data; - this.categoryList.forEach((item, index) => { - item.selected = this.categoryId.indexOf(item.category_id.toString()) != -1; - if (item.selected) { - this.secondCategory = item.child_list; - this.currentLevel = 1; - } - if (item.child_list) { - if (item.selected) this.lastLevel = 2; - item.child_list.forEach(secondItem => { - secondItem.selected = this.categoryId.indexOf(secondItem.category_id.toString()) != -1; - if (secondItem.selected) { - this.thirdCategory = secondItem.child_list; - this.currentLevel = 2; - } - if (secondItem.child_list) { - if (secondItem.selected) this.lastLevel = 3; - secondItem.child_list.forEach(thirdItem => { - thirdItem.selected = this.categoryId.indexOf(thirdItem.category_id.toString()) != -1; - if (thirdItem.selected) this.currentLevel = 3; - }); - } - }); - } - }); - this.changeShow(this.lastLevel); - if (this.goodsData.goods_id == 0 && this.$refs.loadingCover) { - if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); - } - } - }); - }, - changeShow(index) { - if (index == 1) { - this.showFisrt = true; - this.showSecond = false; - this.showThird = false; - } else if (index == 2) { - this.showFisrt = false; - this.showSecond = true; - this.showThird = false; - } else if (index == 3) { - this.showFisrt = false; - this.showSecond = false; - this.showThird = true; - } - this.currentLevel = index; - this.$forceUpdate(); - }, - selectCategory(category) { - this.currentLevel = category.level; - - // 如果当前选中跟上次不一样,则 要清空下级数据 - if (category.level == 1 && this.categoryId[0] > 0 && this.categoryId[0] != category.captcha_id) { - this.categoryId[1] = 0; - this.categoryName[1] = ''; - this.categoryId[2] = 0; - this.categoryName[2] = ''; - } else if (category.level == 2 && this.categoryId[1] > 0 && this.categoryId[1] != category.captcha_id) { - this.categoryId[2] = 0; - this.categoryName[2] = ''; - } - - this.categoryId[category.level - 1] = category.category_id; - this.categoryName[category.level - 1] = category.category_name; - if (category.level == 1) { - if (category.child_list) { - this.secondCategory = category.child_list; - } else { - this.categoryId[1] = 0; - this.categoryName[1] = ''; - this.categoryId[2] = 0; - this.categoryName[2] = ''; - } - } else if (category.level == 2) { - if (category.child_list) { - this.thirdCategory = category.child_list; - } else { - this.categoryId[2] = 0; - this.categoryName[2] = ''; - } - } - - this.lastLevel = 1; - this.categoryList.forEach((item, index) => { - item.selected = this.categoryId[0] == item.category_id; - if (item.child_list) { - if (item.selected) this.lastLevel = 2; - item.child_list.forEach((secondItem, secondIndex) => { - secondItem.selected = this.categoryId[1] == secondItem.category_id; - if (secondItem.child_list) { - if (secondItem.selected) this.lastLevel = 3; - } - }); - } - }); - - this.changeShow(this.lastLevel); - - this.goodsData.category_id = []; - this.goodsData.category_name = []; - - for (var i = 0; i < this.categoryId.length; i++) { - if (this.categoryId[i]) this.goodsData.category_id.push(this.categoryId[i]); - } - for (var i = 0; i < this.categoryName.length; i++) { - if (this.categoryName[i]) this.goodsData.category_name.push(this.categoryName[i]); - } - - this.goodsData.category_id = this.goodsData.category_id.toString(); - this.goodsData.category_name = this.goodsData.category_name.join(" / "); - - if ( - (this.lastLevel == 3 && this.categoryId[2]) || - (this.lastLevel == 2 && this.categoryId[1]) || - (this.lastLevel == 1 && this.categoryId[0]) - ) { - this.shopCategoryData['store_' + this.currCategory] = { - category_id: this.goodsData.category_id, - category_name: this.goodsData.category_name - }; - this.closeGoodsCategoryPop(); - } - - this.$forceUpdate(); - }, - addShopCategory() { - if (this.shopCategoryNumber == 10) { - this.$util.showToast({ - title: '商品可以属于多个分类,最多10个' - }); - return; - } - this.shopCategoryData['store_' + this.shopCategoryNumber] = {}; - ++this.shopCategoryNumber; - }, - deleteShopCategory(index) { - delete this.shopCategoryData['store_' + index]; - --this.shopCategoryNumber; - - //重置数据 - let i = 0; - let obj = {}; - for (let key in this.shopCategoryData) { - obj['store_' + i] = this.shopCategoryData[key]; - i++; - } - this.shopCategoryData = {}; - this.shopCategoryData = Object.assign(this.shopCategoryData, obj); - }, - // 刷新数据 - refreshData() { - var selectedAlbumImg = uni.getStorageSync('selectedAlbumImg'); - if (selectedAlbumImg) { - uni.setStorageSync('selectedAlbumImgTemp', selectedAlbumImg); - selectedAlbumImg = JSON.parse(selectedAlbumImg); - this.goodsData.goods_image = selectedAlbumImg.list.split(","); - this.$refs.goodsShmilyDragImg.refresh(); - } - - // 规格项 - this.goodsData.goods_spec_format = uni.getStorageSync('editGoodsSpecFormat') ? JSON.parse(uni.getStorageSync('editGoodsSpecFormat')) : []; - if (this.goodsData.goods_spec_format.length <= 0) { - - this.goodsData.carmichael = uni.getStorageSync('editGoodsCarmichael') ? JSON.parse(uni.getStorageSync('editGoodsCarmichael')) : []; - if (this.goodsData.carmichael.length > 0) { - this.carmiLength = '添加卡密【' + this.goodsData.carmichael.length + '】' - } - } - - // 多规格数据 - this.goodsData.goods_sku_data = uni.getStorageSync('editGoodsSkuData') ? JSON.parse(uni.getStorageSync('editGoodsSkuData')) : []; - if (this.goodsData.goods_sku_data.length > 0) { - this.goodsData.goods_stock = 0; - this.goodsData.goods_stock_alarm = 0; - this.goodsData.goods_sku_data.forEach((item) => { - if (item.stock) this.goodsData.goods_stock += parseInt(item.stock); - if (item.stock_alarm) this.goodsData.goods_stock_alarm += parseInt(item.stock_alarm); - }); - } - - // 快递运费 - this.goodsData.shipping_template = uni.getStorageSync('editGoodsShippingTemplateId') || 0; - this.goodsData.is_free_shipping = this.goodsData.shipping_template > 0 ? 0 : 1; - this.goodsData.template_name = uni.getStorageSync('editGoodsShippingTemplateName') || ''; - - if (uni.getStorageSync('editGoodsState') !== undefined && uni.getStorageSync('editGoodsState') !== '') { - this.goodsData.goods_state = uni.getStorageSync('editGoodsState'); - } - - if (uni.getStorageSync('editGoodsContent') != undefined && uni.getStorageSync('editGoodsContent') != '') { - this.goodsData.goods_content = uni.getStorageSync('editGoodsContent'); - } - // 商品参数 - this.goodsData.goods_attr_class = uni.getStorageSync('editGoodsAttrClass') || 0; - this.goodsData.goods_attr_name = uni.getStorageSync('editGoodsAttrName') || ''; - this.goodsData.goods_attr_format = uni.getStorageSync('editGoodsAttrFormat') ? JSON.parse(uni.getStorageSync('editGoodsAttrFormat')) : []; - this.$forceUpdate(); - }, - // 验证 - verify() { - - if (this.goodsData.goodsname.length == 0) { - this.$util.showToast({ - title: '请输入商品名称' - }); - return false; - } - - if (this.goodsData.subtitle.length > 100) { - this.$util.showToast({ - title: '商品简介不能超过100个字符' - }); - return false; - } - - if (this.goodsData.goods_image.length == 0) { - this.$util.showToast({ - title: '请上传商品图片' - }); - return false; - } - - - // if (!this.shopCategoryData.store_0.category_id) { - // this.$util.showToast({ - // title: `请选择商品分类` - // }); - // return false; - // } - - // if (this.goodsData.goods_class == 2 && this.goodsData.virtual_deliver_type == 'verify') { - // if (this.goodsData.verify_validity_type == 1) { - // if (this.virtualIndate.length == 0) { - // this.$util.showToast({ - // title: '请输入有效期' - // }); - // return false; - // } - // if (isNaN(this.virtualIndate) || !this.$util.data().regExp.number.test(this.virtualIndate)) { - // this.$util.showToast({ - // title: '[有效期]格式输入错误' - // }); - // return false; - // } - // if (this.virtualIndate < 1) { - // this.$util.showToast({ - // title: '有效期不能小于1天' - // }); - // return false; - // } - // } - - // if (this.goodsData.verify_validity_type == 2) { - // if (this.virtualTime.length == 0) { - // this.$util.showToast({ - // title: '请设置有效期' - // }); - // return false; - // } - // } - - // } - - // 单规格 - if (this.goodsData.price == 0) { - - this.$util.showToast({ - title: '请输入销售价' - }); - return false; - } - if (isNaN(this.goodsData.price) || !this.$util.data().regExp.digit.test(this.goodsData.price)) { - this.$util.showToast({ - title: '[销售价]格式输入错误' - }); - return false; - } - - if (this.goodsData.productprice.length > 0 && (isNaN(this.goodsData.productprice) || !this.$util.data().regExp.digit.test(this.goodsData.productprice))) { - this.$util.showToast({ - title: '[原价价]格式输入错误' - }); - return false; - } - - - - // 总库存 - if (this.goodsData.total == 0) { - this.$util.showToast({ - title: '请输入库存' - }); - return false; - } - - if (isNaN(this.goodsData.total) || !this.$util.data().regExp.number.test(this.goodsData.total)) { - this.$util.showToast({ - title: '[库存]格式输入错误' - }); - return false; - } - if (isNaN(this.goodsData.goods_start_count) || !this.$util.data().regExp.number.test(this.goodsData.goods_start_count)) { - this.$util.showToast({ - title: '[起售]格式输入错误' - }); - return false; - } - if (this.goodsData.goods_start_count < 0) { - this.$util.showToast({ - title: '起售数量不能小于0' - }); - return false; - } - - return true; - - }, - // 删除本地缓存 - clearStoreage() { - - // 临时选择的商品图片 - uni.removeStorageSync("selectedAlbumImg"); - uni.removeStorageSync("selectedAlbumImgTemp"); - - // 商品规格 - uni.removeStorageSync("editGoodsSpecFormat"); - uni.removeStorageSync("editGoodsSkuData"); - - //电子卡密 - uni.removeStorageSync("editGoodsCarmichael"); - uni.removeStorageSync("specName"); - - // 物流公司 - uni.removeStorageSync("editGoodsShippingTemplateId"); - uni.removeStorageSync("editGoodsShippingTemplateName"); - - // 商品状态 - uni.removeStorageSync("editGoodsState"); - - // 商品详情 - uni.removeStorageSync("editGoodsContent"); - - // 商品参数 - uni.removeStorageSync("editGoodsAttrClass"); - uni.removeStorageSync("editGoodsAttrName"); - uni.removeStorageSync("editGoodsAttrFormat"); - }, - save() { - if (!this.verify()) return; - if (this.repeatFlag) return; - this.repeatFlag = true; - this.$api.sendRequest({ - url: 'app.addgoods', - data:this.goodsData, - success: res => { - this.$util.showToast({ - title: res.result.message - }); - if (res.status == 1) { - setTimeout(() => { - this.$util.redirectTo('/pages/goods/list', {}, 'redirectTo'); - }, 1000); - } else { - this.repeatFlag = false; - } - } - }) - - // 清空规格的图片 - console.log(this.goodsData) - return false - for (var i = 0; i < this.goodsData.goods_sku_data.length; i++) { - if (this.goodsData.goods_sku_data[i].sku_images.length == 0) this.goodsData.goods_sku_data[i].sku_image = ''; - } - var data = JSON.parse(JSON.stringify(this.goodsData)); - delete data.category_name; - - data.category_json = []; - data.category_id = ''; - - for (var key in this.shopCategoryData) { - if (this.shopCategoryData[key].category_id) { - data.category_id += ',' + this.shopCategoryData[key].category_id; - data.category_json.push(this.shopCategoryData[key].category_id); - } - } - data.category_id += ','; - data.category_json = JSON.stringify(data.category_json); - if (data.goods_spec_format.length == 0) { - // 单规格数据 - var singData = { - sku_id: (data.goods_id ? data.sku_id : 0), - sku_name: data.goods_name, - spec_name: '', - sku_no: data.sku_no, - sku_spec_format: '', - price: data.price, - market_price: data.market_price, - cost_price: data.cost_price, - stock: data.goods_stock, - stock_alarm: data.goods_stock_alarm, - weight: data.weight, - volume: this.goodsData.volume, - sku_image: data.goods_image[0], - sku_images: data.goods_image.toString(), - // verify_num: data.goods_sku_data.length > 0 ? data.goods_sku_data[0].verify_num : this.goodsData.verify_num - verify_num: data.verify_num - } - var singleSkuData = JSON.stringify([singData]); - } - data.goods_image = data.goods_image.toString(); - // 商品规格json格式 - data.goods_spec_format = data.goods_spec_format.length > 0 ? JSON.stringify(data.goods_spec_format) : ''; - - // SKU商品数据 - data.goods_sku_data = data.goods_spec_format.length > 0 ? JSON.stringify(data.goods_sku_data) : - singleSkuData; - - // 商品参数json格式 - data.goods_attr_format = data.goods_attr_format.length > 0 ? JSON.stringify(data.goods_attr_format) : ''; - - data.spec_type_status = data.goods_spec_format.length > 0 ? 1 : 0; - - if (this.goodsData.verify_validity_type == 1) { - data.virtual_indate = this.virtualIndate; - } else if (this.goodsData.verify_validity_type == 2) { - data.virtual_indate = this.virtualTime; - } - - // console.log(this.goodsData.goods_spec_format,'format') - // if(this.goodsData.goods_spec_format == '[]'){ - // data.carmichael= data.carmichael - // } - var save = null; - if (data.goods_class == 3) { - save = addVirtualCardGoods; - if (data.goods_id) save = editVirtualCardGoods; - }else if (data.goods_class == 2){ - save = addVirtualGoods; - if (data.goods_id) save = editVirtualGoods; - }else { - save = addGoods; - if (data.goods_id) save = editGoods; - } - data.goods_form = this.goodsData.goods_form_index ? this.goodsForm[this.goodsData.goods_form_index - 1].id : 0; - - data.supplier_id = this.goodsData.supply_index ? this.supplyForm[this.goodsData.supply_index - 1].supplier_id : 0; - if (this.repeatFlag) return; - this.repeatFlag = true; - save(data).then(res=>{ - this.$util.showToast({ - title: res.message - }); - if (res.code == 0) { - this.clearStoreage(); - setTimeout(() => { - this.$util.redirectTo('/pages/goods/list', {}, 'tabbar'); - }, 1000); - } else { - this.repeatFlag = false; - } - }); - }, - //是否开启限购 - onLimit() { - this.goodsData.is_limit = this.goodsData.is_limit == 1 ? 0 : 1 - }, - - //限购类型 - limitChange(e) { - this.goodsData.limit_type = e - }, - /** - * 是否参与会员折扣 - */ - joinMemberDiscount() { - this.goodsData.is_consume_discount = this.goodsData.is_consume_discount == 1 ? 0 : 1; - }, - switchBtn(type) { - this.goodsData[type] = this.goodsData[type] == 1 ? 0 : 1; - }, - /** - * 推荐方式选择 - * @param {Object} e - */ - recommendWayChange(e) { - this.goodsData.recommend_way = e.detail.value; - }, - /** - * 发货选择 - * @param {Object} e - */ - virtualDeliverTypeChange(e) { - this.goodsData.virtual_deliver_type = this.virtualDeliverArray[e.detail.value]['value']; - }, - /** - * 收货选择 - * @param {Object} e - */ - virtualReceiveTypeChange(e) { - this.goodsData.virtual_receive_type = this.virtualReceiveArray[e.detail.value]['value']; - }, - /** - * 核销有效期类型 - * @param {Object} e - */ - validityTypeChange(e) { - this.goodsData.verify_validity_type = e.detail.value; - }, - /** - * 核销有效期选择 - * @param {Object} e - */ - virtualTimeChange(e) { - this.virtualTime = e.detail.value; - }, - - /** - * 团购开始时间选择 - * @param {Object} e - */ - beginChange(e) { - this.goodsData.begin_time = e.detail.value; - }, - /** - * 团购结束时间选择 - * @param {Object} e - */ - endChange(e) { - this.goodsData.end_time = e.detail.value; - }, - - /** - * 是否需要核销 - */ - isNeedVerify() { - this.goodsData.is_need_verify = this.goodsData.is_need_verify == 1 ? 0 : 1; - }, - /** - * 获取商品表单 - */ - getGoodsForm() { - getOrderFormList().then(res=>{ - if (res.data) { - let goodsForm = ['请选择商品表单']; - res.data.forEach((item, index) => { - goodsForm.push(item.form_name); - if (this.goodsData.form_id && this.goodsData.form_id == item.id) this.goodsData.goods_form_index = index + 1; - }) - this.goodsForm = res.data; - this.goodsFormArray = goodsForm; - this.$forceUpdate(); - } - }) - }, - goodsFormChange(e) { - this.goodsData.goods_form_index = e.detail.value; - this.$forceUpdate(); - }, - /** - * 获取供应商 - */ - getSupplyList() { - getSupplyList().then(res=>{ - if (res.data) { - let supplyForm = ['请选择供应商']; - res.data.forEach((item, index) => { - supplyForm.push(item.title); - if (this.goodsData.supplier_id && this.goodsData.supplier_id == item.supplier_id) this.goodsData.supply_index = index + 1; - }) - this.supplyForm = res.data; - this.supplyFormArray = supplyForm; - this.$forceUpdate(); - } - }) - }, - supplyChange(e) { - this.goodsData.supply_index = e.detail.value; - this.$forceUpdate(); - } - } +// import {getGoodsInfoById,getCategoryTree,addGoods,editGoods,addVirtualGoods,editVirtualGoods,addVirtualCardGoods,editVirtualCardGoods} from '@/api/goods' +// import {getOrderFormList} from '@/api/form' +// import {getSupplyList} from '@/api/supply' +export default { + data() { + return { + repeatFlag: false, + isIphoneX: false, + goodsImgHeight: 165, // 商品图片高度 + isAWait: false, + albumPage: 'goodsEdit', + //店内分类 + shopCategoryNumber: 1, + shopCategoryData: { + store_0: {} + }, + shopCategoryIndex: '', + + categoryList: [], + secondCategory: [], + thirdCategory: [], + categoryId: [0, 0, 0], + categoryName: ['', '', ''], + currentLevel: 1, + lastLevel: 1, + showFisrt: true, + showSecond: false, + showThird: false, + + goodsData: { + id: 0,//商品id + goodsname:'',//商品名称 + subtitle:'',//商品简介 + is_show_arrive:1,//默认商品预达简介0关闭1开启 + diy_arrive_switch:0,//商品自定义预达简介0关闭1开启 + goods_start_count:1,//起售数量 + grounding:1,//0下架1上架 + is_index_show:1,//0首页不推荐1推荐 + price:0,//售价 + productprice:0,//原价 + costprice:0,//成本价 + total:0,//库存 + pick_up_type:0,//提货时,0当日达1次日达2隔日达3自定义 + dispatchtype:1,//1统一运费 + dispatchprice:0,//统一运费金额 + begin_time:'',//团购开始时间 + end_time:'',//团购结束时间 + oneday_limit_count:0,//每天限购 + one_limit_count:0,//单次限购 + total_limit_count:0,//历史限购 + is_all_sale:0,//所有团长1部分团长0 + goods_image:[], + begin_time:'',//团购开始时间 + end_time:''//团购结束时间 + }, + groundingArray: ['下架', '上架'], + + pickuptypeArray: ['当日达', '次日达', '隔日达'],//, '自定义' + + + currCategory: 0, // 当前所设置的商品分类 + virtualDeliverArray: [{ + name: '自动发货', + value: 'auto_deliver', + }, + { + name: '手动发货', + value: 'artificial_deliver', + }, + { + name: '到店核销', + value: 'verify', + } + ], + virtualDeliverValue: { + 'auto_deliver': '自动发货', + 'artificial_deliver': '手动发货', + 'verify': '到店核销' + }, + virtualReceiveArray: [{ + name: '自动收货', + value: 'auto_receive', + }, + { + name: '买家确认收货', + value: 'artificial_receive', + }, + ], + virtualReceiveValue: { + 'auto_receive': '自动收货', + 'artificial_receive': '买家确认收货', + }, + validityTypeArray: ['永久', '购买后几日有效', '指定过期日期'], + virtualIndate: 0, + minDate: '', + carmiLength: '添加卡密', + limitLength: [ //限购 + { + name: '单次限购', + value: '1' + }, + { + name: '长期限购', + value: '2' + } + ], + current: 0, + goodsFormArray: [], + goodsForm: [], + + supplyFormArray: [], + supplyForm: [] + }; + }, + async onLoad(option) { + this.goodsData.id = option.id || 0; + + // if (!this.$util.checkToken('/pages/goods/edit/index?id=' + this.goodsData.id)) return; + + // this.clearStoreage(); + + // this.getCategoryTreeFn(); + if (this.goodsData.id) { + this.isAWait = true; + uni.setNavigationBarTitle({ + title: '编辑商品' + }); + await this.editGetGoodsInfo(); + } else { + + this.isAWait = false; + uni.setNavigationBarTitle({ + title: '添加商品' + }); + } + + let date = new Date(); + this.minDate = date.getFullYear() + '-' + date.getMonth() + '-' + date.getUTCDate(); + + // if (this.addonIsExit.form) this.getGoodsForm(); + + // if (this.addonIsExit.supply) this.getSupplyList(); + + }, + onShow() { + this.isIphoneX = this.$util.uniappIsIPhoneX(); + //this.refreshData(); + }, + methods: { + + groundingChange(e) { + this.goodsData.grounding = e.detail.value; + }, + + pickuptypeChange(e) { + this.goodsData.pick_up_type = e.detail.value; + }, + + // 获取编辑商品数据 + async editGetGoodsInfo() { + this.$api.sendRequest({ + url: 'app.getgoodsinfo', + data:{ + id:this.goodsData.id + }, + success: res => { + console.log(res) + if(res.result.detail){ + this.goodsData = res.result.detail + console.log(this.goodsData.goods_image) + }else{ + this.$util.showToast({ + title: '商品不存在', + }); + setTimeout(() => { + this.$util.redirectTo('/pages_goods/list', {}, 'redirectTo'); + }, 1000); + } + // if (res.status == 0) { + // setTimeout(() => { + // this.$util.redirectTo('/pages_goods/list', {}, 'redirectTo'); + // }, 1000); + // } + } + }) + /*var res = await getGoodsInfoById(this.goodsData.goods_id); + if (res.code == 0 && res.data) { + var data = res.data; + + data.goods_category.forEach((item, index) => { + this.shopCategoryData['store_' + index] = { + category_id: item.id, + category_name: item.category_name + } + }) + this.shopCategoryNumber = data.goods_category.length; + + // 商品分类 + data.category_id = data.goods_category[0].id; + data.category_name = data.goods_category[0].category_name.replace(/\//g, " / "); + + if (typeof data.category_id == 'string') { + this.categoryId = data.category_id.split(","); + this.categoryName = data.category_name.split(" / "); + } else { + this.categoryId = data.category_id; + this.categoryName = data.category_name; + } + + delete data.category_json; + delete data.goods_category; + + data.goods_image = data.goods_image.split(","); + + data.goods_sku_data.forEach((item) => { + if (item.sku_spec_format) item.sku_spec_format = JSON.parse(item.sku_spec_format); + }); + + if (data.goods_spec_format) { + uni.setStorageSync("editGoodsSpecFormat", data.goods_spec_format); + uni.setStorageSync("editGoodsSkuData", JSON.stringify(data.goods_sku_data)); + data.goods_spec_format = JSON.parse(data.goods_spec_format); + } else { + data.sku_id = data.goods_sku_data[0].sku_id; + data.price = data.goods_sku_data[0].price; + data.market_price = data.goods_sku_data[0].market_price; + data.cost_price = data.goods_sku_data[0].cost_price; + data.weight = data.goods_sku_data[0].weight; + data.volume = data.goods_sku_data[0].volume; + data.sku_no = data.goods_sku_data[0].sku_no; + } + + if (data.goods_class == 1) { + // 实物商品 + delete data.virtual_indate; + uni.setStorageSync("editGoodsShippingTemplateId", data.shipping_template); + uni.setStorageSync("editGoodsShippingTemplateName", data.template_name ? data.template_name : ''); + } else { + // 虚拟商品 + delete data.shipping_template; + delete data.is_free_shipping; + } + + // 商品参数 + if (data.goods_attr_format) { + uni.setStorageSync("editGoodsAttrClass", data.goods_attr_class); + uni.setStorageSync("editGoodsAttrName", data.goods_attr_name); + uni.setStorageSync("editGoodsAttrFormat", data.goods_attr_format); + data.goods_attr_format = JSON.parse(data.goods_attr_format); + } + + uni.setStorageSync("editGoodsState", data.goods_state); + uni.setStorageSync("editGoodsContent", data.goods_content); + + if (data.verify_validity_type == 1) { + this.virtualIndate = data.virtual_indate; + } else if (data.verify_validity_type == 2) { + this.virtualTime = this.$util.timeStampTurnTime(data.virtual_indate, 'Y-m-d'); + } + data.verify_num = data.goods_sku_data[0].verify_num + + this.goodsData = data; + + this.goodsData.goods_form_index = 0; + + this.goodsData.supply_index = 0; + + this.$forceUpdate(); + } else { + this.$util.showToast({ + title: '商品不存在', + }); + setTimeout(() => { + this.$util.redirectTo('/pages_goods/list', {}, 'redirectTo'); + }, 1000); + }*/ + }, + // 选择商品分类 + openGoodsCategoryPop(index) { + this.currCategory = index; + if (this.shopCategoryData['store_' + index].category_id) { + this.categoryId = this.shopCategoryData['store_' + index].category_id.split(','); + this.categoryName = this.shopCategoryData['store_' + index].category_name.split(' / '); + + this.categoryList.forEach((item, index) => { + item.selected = this.categoryId.indexOf(item.category_id.toString()) != -1; + if (item.selected) { + this.secondCategory = item.child_list; + } + if (item.child_list) { + if (item.selected) this.lastLevel = 2; + item.child_list.forEach(secondItem => { + secondItem.selected = this.categoryId.indexOf(secondItem.category_id.toString()) != -1; + if (secondItem.selected) { + this.thirdCategory = secondItem.child_list; + } + }); + } + }); + this.changeShow(this.categoryId.length); + } else { + this.categoryId = [0]; + this.categoryName = ['']; + this.changeShow(1); + } + this.$refs.categoryPopup.open(); + }, + closeGoodsCategoryPop() { + this.$refs.categoryPopup.close(); + }, + // 编辑规格类型 + openGoodsSpec() { + this.$util.redirectTo('/pages/goods/edit/spec'); + }, + // 编辑多规格 + openGoodsSpecEdit() { + this.$util.redirectTo('/pages/goods/edit/spec_edit', { + goods_class: this.goodsData.goods_class, + virtual_deliver_type: this.goodsData.virtual_deliver_type + }); + }, + //编辑卡密 + openCarmichaelEdit() { + this.$util.redirectTo('/pages/goods/edit/carmichael_edit', { + goods_class: this.goodsData.goods_class + }); + }, + // 编辑商品状态 + openGoodsState() { + this.$util.redirectTo('/pages/goods/edit/state', { + goods_state: this.goodsData.goods_state + }); + }, + // 编辑快递运费 + openExpressFreight() { + this.$util.redirectTo('/pages/goods/edit/express_freight', { + template_id: this.goodsData.shipping_template + }); + }, + // 编辑商品详情 + openGoodsContent() { + this.$util.redirectTo('/pages/goods/edit/content'); + }, + // 编辑商品参数 + openAttr() { + this.$util.redirectTo('/pages/goods/edit/attr'); + }, + /** + * 刷新商品图片高度 + * @param {Object} data + */ + refreshGoodsImgHeight(data) { + if (data.height == '') return; + var height = parseFloat(data.height.replace('px', '')); + this.goodsImgHeight = height + 80; + this.$forceUpdate(); + if (data.isLoad && this.$refs.loadingCover) { + // 数据渲染留点时间 + setTimeout(() => { + this.$refs.loadingCover.hide(); + }, 100); + } + uni.removeStorageSync("selectedAlbumImg"); + + }, + // 获取商品分类树状结构 + getCategoryTreeFn() { + getCategoryTree().then(res=>{ + if (res.data) { + this.categoryList = res.data; + this.categoryList.forEach((item, index) => { + item.selected = this.categoryId.indexOf(item.category_id.toString()) != -1; + if (item.selected) { + this.secondCategory = item.child_list; + this.currentLevel = 1; + } + if (item.child_list) { + if (item.selected) this.lastLevel = 2; + item.child_list.forEach(secondItem => { + secondItem.selected = this.categoryId.indexOf(secondItem.category_id.toString()) != -1; + if (secondItem.selected) { + this.thirdCategory = secondItem.child_list; + this.currentLevel = 2; + } + if (secondItem.child_list) { + if (secondItem.selected) this.lastLevel = 3; + secondItem.child_list.forEach(thirdItem => { + thirdItem.selected = this.categoryId.indexOf(thirdItem.category_id.toString()) != -1; + if (thirdItem.selected) this.currentLevel = 3; + }); + } + }); + } + }); + this.changeShow(this.lastLevel); + if (this.goodsData.goods_id == 0 && this.$refs.loadingCover) { + if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); + } + } + }); + }, + changeShow(index) { + if (index == 1) { + this.showFisrt = true; + this.showSecond = false; + this.showThird = false; + } else if (index == 2) { + this.showFisrt = false; + this.showSecond = true; + this.showThird = false; + } else if (index == 3) { + this.showFisrt = false; + this.showSecond = false; + this.showThird = true; + } + this.currentLevel = index; + this.$forceUpdate(); + }, + selectCategory(category) { + this.currentLevel = category.level; + + // 如果当前选中跟上次不一样,则 要清空下级数据 + if (category.level == 1 && this.categoryId[0] > 0 && this.categoryId[0] != category.captcha_id) { + this.categoryId[1] = 0; + this.categoryName[1] = ''; + this.categoryId[2] = 0; + this.categoryName[2] = ''; + } else if (category.level == 2 && this.categoryId[1] > 0 && this.categoryId[1] != category.captcha_id) { + this.categoryId[2] = 0; + this.categoryName[2] = ''; + } + + this.categoryId[category.level - 1] = category.category_id; + this.categoryName[category.level - 1] = category.category_name; + if (category.level == 1) { + if (category.child_list) { + this.secondCategory = category.child_list; + } else { + this.categoryId[1] = 0; + this.categoryName[1] = ''; + this.categoryId[2] = 0; + this.categoryName[2] = ''; + } + } else if (category.level == 2) { + if (category.child_list) { + this.thirdCategory = category.child_list; + } else { + this.categoryId[2] = 0; + this.categoryName[2] = ''; + } + } + + this.lastLevel = 1; + this.categoryList.forEach((item, index) => { + item.selected = this.categoryId[0] == item.category_id; + if (item.child_list) { + if (item.selected) this.lastLevel = 2; + item.child_list.forEach((secondItem, secondIndex) => { + secondItem.selected = this.categoryId[1] == secondItem.category_id; + if (secondItem.child_list) { + if (secondItem.selected) this.lastLevel = 3; + } + }); + } + }); + + this.changeShow(this.lastLevel); + + this.goodsData.category_id = []; + this.goodsData.category_name = []; + + for (var i = 0; i < this.categoryId.length; i++) { + if (this.categoryId[i]) this.goodsData.category_id.push(this.categoryId[i]); + } + for (var i = 0; i < this.categoryName.length; i++) { + if (this.categoryName[i]) this.goodsData.category_name.push(this.categoryName[i]); + } + + this.goodsData.category_id = this.goodsData.category_id.toString(); + this.goodsData.category_name = this.goodsData.category_name.join(" / "); + + if ( + (this.lastLevel == 3 && this.categoryId[2]) || + (this.lastLevel == 2 && this.categoryId[1]) || + (this.lastLevel == 1 && this.categoryId[0]) + ) { + this.shopCategoryData['store_' + this.currCategory] = { + category_id: this.goodsData.category_id, + category_name: this.goodsData.category_name + }; + this.closeGoodsCategoryPop(); + } + + this.$forceUpdate(); + }, + addShopCategory() { + if (this.shopCategoryNumber == 10) { + this.$util.showToast({ + title: '商品可以属于多个分类,最多10个' + }); + return; + } + this.shopCategoryData['store_' + this.shopCategoryNumber] = {}; + ++this.shopCategoryNumber; + }, + deleteShopCategory(index) { + delete this.shopCategoryData['store_' + index]; + --this.shopCategoryNumber; + + //重置数据 + let i = 0; + let obj = {}; + for (let key in this.shopCategoryData) { + obj['store_' + i] = this.shopCategoryData[key]; + i++; + } + this.shopCategoryData = {}; + this.shopCategoryData = Object.assign(this.shopCategoryData, obj); + }, + // 刷新数据 + refreshData() { + var selectedAlbumImg = uni.getStorageSync('selectedAlbumImg'); + if (selectedAlbumImg) { + uni.setStorageSync('selectedAlbumImgTemp', selectedAlbumImg); + selectedAlbumImg = JSON.parse(selectedAlbumImg); + this.goodsData.goods_image = selectedAlbumImg.list.split(","); + this.$refs.goodsShmilyDragImg.refresh(); + } + + // 规格项 + this.goodsData.goods_spec_format = uni.getStorageSync('editGoodsSpecFormat') ? JSON.parse(uni.getStorageSync('editGoodsSpecFormat')) : []; + if (this.goodsData.goods_spec_format.length <= 0) { + + this.goodsData.carmichael = uni.getStorageSync('editGoodsCarmichael') ? JSON.parse(uni.getStorageSync('editGoodsCarmichael')) : []; + if (this.goodsData.carmichael.length > 0) { + this.carmiLength = '添加卡密【' + this.goodsData.carmichael.length + '】' + } + } + + // 多规格数据 + this.goodsData.goods_sku_data = uni.getStorageSync('editGoodsSkuData') ? JSON.parse(uni.getStorageSync('editGoodsSkuData')) : []; + if (this.goodsData.goods_sku_data.length > 0) { + this.goodsData.goods_stock = 0; + this.goodsData.goods_stock_alarm = 0; + this.goodsData.goods_sku_data.forEach((item) => { + if (item.stock) this.goodsData.goods_stock += parseInt(item.stock); + if (item.stock_alarm) this.goodsData.goods_stock_alarm += parseInt(item.stock_alarm); + }); + } + + // 快递运费 + this.goodsData.shipping_template = uni.getStorageSync('editGoodsShippingTemplateId') || 0; + this.goodsData.is_free_shipping = this.goodsData.shipping_template > 0 ? 0 : 1; + this.goodsData.template_name = uni.getStorageSync('editGoodsShippingTemplateName') || ''; + + if (uni.getStorageSync('editGoodsState') !== undefined && uni.getStorageSync('editGoodsState') !== '') { + this.goodsData.goods_state = uni.getStorageSync('editGoodsState'); + } + + if (uni.getStorageSync('editGoodsContent') != undefined && uni.getStorageSync('editGoodsContent') != '') { + this.goodsData.goods_content = uni.getStorageSync('editGoodsContent'); + } + // 商品参数 + this.goodsData.goods_attr_class = uni.getStorageSync('editGoodsAttrClass') || 0; + this.goodsData.goods_attr_name = uni.getStorageSync('editGoodsAttrName') || ''; + this.goodsData.goods_attr_format = uni.getStorageSync('editGoodsAttrFormat') ? JSON.parse(uni.getStorageSync('editGoodsAttrFormat')) : []; + this.$forceUpdate(); + }, + // 验证 + verify() { + + if (this.goodsData.goodsname.length == 0) { + this.$util.showToast({ + title: '请输入商品名称' + }); + return false; + } + + if (this.goodsData.subtitle.length > 100) { + this.$util.showToast({ + title: '商品简介不能超过100个字符' + }); + return false; + } + + if (this.goodsData.goods_image.length == 0) { + this.$util.showToast({ + title: '请上传商品图片' + }); + return false; + } + + + // if (!this.shopCategoryData.store_0.category_id) { + // this.$util.showToast({ + // title: `请选择商品分类` + // }); + // return false; + // } + + // if (this.goodsData.goods_class == 2 && this.goodsData.virtual_deliver_type == 'verify') { + // if (this.goodsData.verify_validity_type == 1) { + // if (this.virtualIndate.length == 0) { + // this.$util.showToast({ + // title: '请输入有效期' + // }); + // return false; + // } + // if (isNaN(this.virtualIndate) || !this.$util.data().regExp.number.test(this.virtualIndate)) { + // this.$util.showToast({ + // title: '[有效期]格式输入错误' + // }); + // return false; + // } + // if (this.virtualIndate < 1) { + // this.$util.showToast({ + // title: '有效期不能小于1天' + // }); + // return false; + // } + // } + + // if (this.goodsData.verify_validity_type == 2) { + // if (this.virtualTime.length == 0) { + // this.$util.showToast({ + // title: '请设置有效期' + // }); + // return false; + // } + // } + + // } + + // 单规格 + if (this.goodsData.price == 0) { + + this.$util.showToast({ + title: '请输入销售价' + }); + return false; + } + if (isNaN(this.goodsData.price) || !this.$util.data().regExp.digit.test(this.goodsData.price)) { + this.$util.showToast({ + title: '[销售价]格式输入错误' + }); + return false; + } + + if (this.goodsData.productprice.length > 0 && (isNaN(this.goodsData.productprice) || !this.$util.data().regExp.digit.test(this.goodsData.productprice))) { + this.$util.showToast({ + title: '[原价价]格式输入错误' + }); + return false; + } + + + + // 总库存 + if (this.goodsData.total == 0) { + this.$util.showToast({ + title: '请输入库存' + }); + return false; + } + + if (isNaN(this.goodsData.total) || !this.$util.data().regExp.number.test(this.goodsData.total)) { + this.$util.showToast({ + title: '[库存]格式输入错误' + }); + return false; + } + if (isNaN(this.goodsData.goods_start_count) || !this.$util.data().regExp.number.test(this.goodsData.goods_start_count)) { + this.$util.showToast({ + title: '[起售]格式输入错误' + }); + return false; + } + if (this.goodsData.goods_start_count < 0) { + this.$util.showToast({ + title: '起售数量不能小于0' + }); + return false; + } + + return true; + + }, + // 删除本地缓存 + clearStoreage() { + + // 临时选择的商品图片 + uni.removeStorageSync("selectedAlbumImg"); + uni.removeStorageSync("selectedAlbumImgTemp"); + + // 商品规格 + uni.removeStorageSync("editGoodsSpecFormat"); + uni.removeStorageSync("editGoodsSkuData"); + + //电子卡密 + uni.removeStorageSync("editGoodsCarmichael"); + uni.removeStorageSync("specName"); + + // 物流公司 + uni.removeStorageSync("editGoodsShippingTemplateId"); + uni.removeStorageSync("editGoodsShippingTemplateName"); + + // 商品状态 + uni.removeStorageSync("editGoodsState"); + + // 商品详情 + uni.removeStorageSync("editGoodsContent"); + + // 商品参数 + uni.removeStorageSync("editGoodsAttrClass"); + uni.removeStorageSync("editGoodsAttrName"); + uni.removeStorageSync("editGoodsAttrFormat"); + }, + save() { + if (!this.verify()) return; + if (this.repeatFlag) return; + this.repeatFlag = true; + this.$api.sendRequest({ + url: 'app.addgoods', + data:this.goodsData, + success: res => { + this.$util.showToast({ + title: res.result.message + }); + if (res.status == 1) { + setTimeout(() => { + this.$util.redirectTo('/pages_goods/list', {}, 'redirectTo'); + }, 1000); + } else { + this.repeatFlag = false; + } + } + }) + + // 清空规格的图片 + console.log(this.goodsData) + return false + for (var i = 0; i < this.goodsData.goods_sku_data.length; i++) { + if (this.goodsData.goods_sku_data[i].sku_images.length == 0) this.goodsData.goods_sku_data[i].sku_image = ''; + } + var data = JSON.parse(JSON.stringify(this.goodsData)); + delete data.category_name; + + data.category_json = []; + data.category_id = ''; + + for (var key in this.shopCategoryData) { + if (this.shopCategoryData[key].category_id) { + data.category_id += ',' + this.shopCategoryData[key].category_id; + data.category_json.push(this.shopCategoryData[key].category_id); + } + } + data.category_id += ','; + data.category_json = JSON.stringify(data.category_json); + if (data.goods_spec_format.length == 0) { + // 单规格数据 + var singData = { + sku_id: (data.goods_id ? data.sku_id : 0), + sku_name: data.goods_name, + spec_name: '', + sku_no: data.sku_no, + sku_spec_format: '', + price: data.price, + market_price: data.market_price, + cost_price: data.cost_price, + stock: data.goods_stock, + stock_alarm: data.goods_stock_alarm, + weight: data.weight, + volume: this.goodsData.volume, + sku_image: data.goods_image[0], + sku_images: data.goods_image.toString(), + // verify_num: data.goods_sku_data.length > 0 ? data.goods_sku_data[0].verify_num : this.goodsData.verify_num + verify_num: data.verify_num + } + var singleSkuData = JSON.stringify([singData]); + } + data.goods_image = data.goods_image.toString(); + // 商品规格json格式 + data.goods_spec_format = data.goods_spec_format.length > 0 ? JSON.stringify(data.goods_spec_format) : ''; + + // SKU商品数据 + data.goods_sku_data = data.goods_spec_format.length > 0 ? JSON.stringify(data.goods_sku_data) : + singleSkuData; + + // 商品参数json格式 + data.goods_attr_format = data.goods_attr_format.length > 0 ? JSON.stringify(data.goods_attr_format) : ''; + + data.spec_type_status = data.goods_spec_format.length > 0 ? 1 : 0; + + if (this.goodsData.verify_validity_type == 1) { + data.virtual_indate = this.virtualIndate; + } else if (this.goodsData.verify_validity_type == 2) { + data.virtual_indate = this.virtualTime; + } + + // console.log(this.goodsData.goods_spec_format,'format') + // if(this.goodsData.goods_spec_format == '[]'){ + // data.carmichael= data.carmichael + // } + var save = null; + if (data.goods_class == 3) { + save = addVirtualCardGoods; + if (data.goods_id) save = editVirtualCardGoods; + }else if (data.goods_class == 2){ + save = addVirtualGoods; + if (data.goods_id) save = editVirtualGoods; + }else { + save = addGoods; + if (data.goods_id) save = editGoods; + } + data.goods_form = this.goodsData.goods_form_index ? this.goodsForm[this.goodsData.goods_form_index - 1].id : 0; + + data.supplier_id = this.goodsData.supply_index ? this.supplyForm[this.goodsData.supply_index - 1].supplier_id : 0; + if (this.repeatFlag) return; + this.repeatFlag = true; + save(data).then(res=>{ + this.$util.showToast({ + title: res.message + }); + if (res.code == 0) { + this.clearStoreage(); + setTimeout(() => { + this.$util.redirectTo('/pages_goods/list', {}, 'tabbar'); + }, 1000); + } else { + this.repeatFlag = false; + } + }); + }, + //是否开启限购 + onLimit() { + this.goodsData.is_limit = this.goodsData.is_limit == 1 ? 0 : 1 + }, + + //限购类型 + limitChange(e) { + this.goodsData.limit_type = e + }, + /** + * 是否参与会员折扣 + */ + joinMemberDiscount() { + this.goodsData.is_consume_discount = this.goodsData.is_consume_discount == 1 ? 0 : 1; + }, + switchBtn(type) { + this.goodsData[type] = this.goodsData[type] == 1 ? 0 : 1; + }, + /** + * 推荐方式选择 + * @param {Object} e + */ + recommendWayChange(e) { + this.goodsData.recommend_way = e.detail.value; + }, + /** + * 发货选择 + * @param {Object} e + */ + virtualDeliverTypeChange(e) { + this.goodsData.virtual_deliver_type = this.virtualDeliverArray[e.detail.value]['value']; + }, + /** + * 收货选择 + * @param {Object} e + */ + virtualReceiveTypeChange(e) { + this.goodsData.virtual_receive_type = this.virtualReceiveArray[e.detail.value]['value']; + }, + /** + * 核销有效期类型 + * @param {Object} e + */ + validityTypeChange(e) { + this.goodsData.verify_validity_type = e.detail.value; + }, + /** + * 核销有效期选择 + * @param {Object} e + */ + virtualTimeChange(e) { + this.virtualTime = e.detail.value; + }, + + /** + * 团购开始时间选择 + * @param {Object} e + */ + beginChange(e) { + this.goodsData.begin_time = e.detail.value; + }, + /** + * 团购结束时间选择 + * @param {Object} e + */ + endChange(e) { + this.goodsData.end_time = e.detail.value; + }, + + /** + * 是否需要核销 + */ + isNeedVerify() { + this.goodsData.is_need_verify = this.goodsData.is_need_verify == 1 ? 0 : 1; + }, + /** + * 获取商品表单 + */ + getGoodsForm() { + getOrderFormList().then(res=>{ + if (res.data) { + let goodsForm = ['请选择商品表单']; + res.data.forEach((item, index) => { + goodsForm.push(item.form_name); + if (this.goodsData.form_id && this.goodsData.form_id == item.id) this.goodsData.goods_form_index = index + 1; + }) + this.goodsForm = res.data; + this.goodsFormArray = goodsForm; + this.$forceUpdate(); + } + }) + }, + goodsFormChange(e) { + this.goodsData.goods_form_index = e.detail.value; + this.$forceUpdate(); + }, + /** + * 获取供应商 + */ + getSupplyList() { + getSupplyList().then(res=>{ + if (res.data) { + let supplyForm = ['请选择供应商']; + res.data.forEach((item, index) => { + supplyForm.push(item.title); + if (this.goodsData.supplier_id && this.goodsData.supplier_id == item.supplier_id) this.goodsData.supply_index = index + 1; + }) + this.supplyForm = res.data; + this.supplyFormArray = supplyForm; + this.$forceUpdate(); + } + }) + }, + supplyChange(e) { + this.goodsData.supply_index = e.detail.value; + this.$forceUpdate(); + } + } }; \ No newline at end of file diff --git a/pages_promotion/merch/public/js/list.js b/pages_promotion/merch/public/js/list.js index 5496bc4..a6d244e 100644 --- a/pages_promotion/merch/public/js/list.js +++ b/pages_promotion/merch/public/js/list.js @@ -1,475 +1,475 @@ -export default { - data() { - return { - listStyle: '', - loadingType: 'loading', //加载更多状态 - orderType: '', - priceOrder: 'desc', //1 价格从低到高 2价格从高到低 - categoryList: [], //排序类型 - goodsList: [], - order: '', - sort: 'desc', - showScreen: false, - keyword: '', - categoryId: 0, - minPrice: '', - maxPrice: '', - isFreeShipping: false, //是否免邮 - isIphoneX: false, - coupon: 0, - emptyShow: false, - isList: true, //列表样式 - //分享所需标题 - share_title: '', - //搜索到多少件商品 - count: 0, - //当前分类名称 - category_title: '', - //优惠券数据 - coupon_name: '', - //列表瀑布流数据 - listHeight: [], - listPosition: [], - debounce: null, - brandId: 0, - merch_id:0, - merch:{}, - brandList: [], //品牌筛选项 - config: { - fontWeight: false, - padding: 0, - cartEvent: "detail", - text: "购买", - textColor: "#FFFFFF", - theme: "default", - aroundRadius: 25, - control: true, - bgColor: "#FF6A00", - style: "button", - iconDiy: { - iconType: "icon", - icon: "", - style: { - fontSize: "60", - iconBgColor: [], - iconBgColorDeg: 0, - iconBgImg: "", - bgRadius: 0, - iconColor: [ - "#000000" - ], - iconColorDeg: 0 - } - } - }, - } - }, - - onLoad(options) { - this.categoryId = options.category_id || 0; - this.keyword = options.keyword || ''; - this.coupon = options.coupon || 0; - this.goods_id_arr = options.goods_id_arr || 0; - this.brandId = options.brand_id || 0; - this.merch_id = options.merch_id || 0; - if(this.merch_id > 0){ - this.getMerch() - }else{ - uni.showModal({ - title:'提示', - content:'商家不存在', - showCancel:false, - success(e){ - uni.navigateBack({}) - } - }) - } - this.loadCategoryList(this.categoryId); - this.getBrandList(); - this.isIphoneX = this.$util.uniappIsIPhoneX(); - - //小程序分享接收source_member - if (options.source_member) { - uni.setStorageSync('source_member', options.source_member); - } - // 小程序扫码进入,接收source_member - if (options.scene) { - var sceneParams = decodeURIComponent(options.scene); - sceneParams = sceneParams.split('&'); - if (sceneParams.length) { - sceneParams.forEach(item => { - if (item.indexOf('sku_id') != -1) this.skuId = item.split('-')[1]; - if (item.indexOf('m') != -1) uni.setStorageSync('source_member', item.split('-')[1]); - if (item.indexOf('is_test') != -1) uni.setStorageSync('is_test', 1); - }); - } - } - - uni.onWindowResize(res => { - if (this.debounce) clearTimeout(this.debounce); - this.waterfallflow(0); - }) - }, - onShow() { - //记录分享关系 - if (this.storeToken && uni.getStorageSync('source_member')) { - this.$util.onSourceMember(uni.getStorageSync('source_member')); - } - }, - /** - * 转发分享 - */ - onShareAppMessage(res) { - var title = '搜索到' + this.count + '件“' + this.keyword + this.category_title + this.coupon_name + '”相关的优质商品'; - let route = this.$util.getCurrentShareRoute(this.memberInfo ? this.memberInfo.member_id : 0); - var path = route.path; - return { - title: title, - path: path, - success: res => { - }, - fail: res => { - } - }; - }, - // 分享到微信朋友圈 - onShareTimeline() { - var title = '搜索到' + this.count + '件“' + this.keyword + this.category_title + this.coupon_name + '”相关的优质商品'; - let route = this.$util.getCurrentShareRoute(this.memberInfo ? this.memberInfo.member_id : 0); - var query = route.query; - return { - title: title, - query: query, - imageUrl: '' - }; - }, - methods: { - getMerch(){ - this.$api.sendRequest({ - url: '/merch/api/merch/merchinfo', - data: { - merch_id:this.merch_id - }, - success: res => { - console.log(res) - this.merch = res.data - } - }); - }, - /** - * 获取优惠券数据 - */ - couponInfo(id) { - return new Promise(resolve => { - this.$api.sendRequest({ - url: '/coupon/api/coupon/typeinfo', - data: { - coupon_type_id: id - }, - success: res => { - if (res.code >= 0) { - resolve(res.data.coupon_name); - } - } - }); - }) - }, - /** - * 获取分类名称 - */ - share_select(data, id) { - return new Promise((resolve) => { - data.forEach((item) => { - if (item.category_id == id) { - resolve(item.category_name) - } - if (item.child_list && item.child_list.length > 0) { - item.child_list.forEach((v) => { - if (v.category_id == id) { - resolve(v.category_name) - } - if (v.child_list && v.child_list.length > 0) { - v.forEach((m) => { - if (m.category_id == id) { - resolve(m.category_name) - } - }) - - } - }) - } - }) - }) - }, - //加载分类 - loadCategoryList(fid, sid) { - this.$api.sendRequest({ - url: '/api/goodscategory/tree', - data: {}, - success: res => { - if (res.data != null) { - this.categoryList = res.data - } - } - }); - }, - getGoodsList(mescroll) { - this.$api.sendRequest({ - url: '/api/goodssku/page', - data: { - page: mescroll.num, - page_size: mescroll.size, - keyword: this.keyword, - category_id: this.categoryId, - brand_id: this.brandId, - min_price: this.minPrice, - max_price: this.maxPrice, - is_free_shipping: (this.isFreeShipping ? 1 : 0), - order: this.order, - sort: this.sort, - coupon: this.coupon, - goods_id_arr: this.goods_id_arr, - merch_id:this.merch_id - }, - success: res => { - let newArr = [] - let msg = res.message; - if (res.code == 0 && res.data) { - this.count = res.data.count; - if (res.data.page_count == 0) { - this.emptyShow = true - } - newArr = res.data.list; - newArr = newArr.map(item => { - item.id = this.genNonDuplicate(); - return item; - }); - } else { - this.$util.showToast({ - title: msg - }) - } - this.category_title = ''; - this.coupon_name = ''; - if (res.data.config) this.config = res.data.config; - if (this.categoryId) { - this.share_select(this.categoryList, this.categoryId).then(resolve => { - this.category_title = resolve - }); - } - if (this.coupon) { - this.couponInfo(this.coupon).then(resolve => { - this.coupon_name = resolve - }); - } - mescroll.endSuccess(newArr.length); - //设置列表数据 - if (mescroll.num == 1) this.goodsList = []; //如果是第一页需手动制空列表 - this.goodsList = this.goodsList.concat(newArr); //追加新数据 - if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); - - this.waterfallflow((mescroll.num - 1) * 10); - }, - fail: res => { - //联网失败的回调 - mescroll.endErr(); - if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); - } - }); - }, - changeListStyle() { - this.isList = !this.isList; - this.waterfallflow(0); - }, - //筛选点击 - sortTabClick(tag) { - if (tag == 'sale_num') { - this.order = 'sale_num'; - this.sort = 'desc'; - } else if (tag == 'discount_price') { - this.order = 'discount_price'; - this.sort = 'desc'; - } else if (tag == 'screen') { - //筛选 - this.showScreen = true; - return; - } else { - this.order = ''; - this.sort = ''; - } - - if (this.orderType === tag && tag !== 'discount_price') return; - - this.orderType = tag; - if (tag === 'discount_price') { - this.priceOrder = this.priceOrder === 'asc' ? 'desc' : 'asc'; - this.sort = this.priceOrder; - } else { - this.priceOrder = ''; - } - this.emptyShow = false; - this.goodsList = []; - this.$refs.mescroll.refresh(); - }, - //商品详情 - toDetail(item) { - this.$util.redirectTo('/pages/goods/detail', { - goods_id: item.goods_id - }); - }, - search() { - this.emptyShow = false; - this.goodsList = []; - this.$refs.mescroll.refresh(); - }, - selectedCategory(categoryId) { - this.categoryId = categoryId; - }, - screenData() { - if (this.minPrice != '' || this.maxPrice != '') { - // if (!Number(this.minPrice) && this.minPrice) { - // this.$util.showToast({ - // title: '请输入最低价' - // }); - // return; - // } - if (!Number(this.maxPrice) && this.maxPrice) { - this.$util.showToast({ - title: '请输入最高价' - }); - return; - } - if (Number(this.minPrice) < 0 || Number(this.maxPrice) < 0) { - this.$util.showToast({ - title: '筛选价格不能小于0' - }); - return; - } - if (this.minPrice != '' && Number(this.minPrice) > Number(this.maxPrice) && this.maxPrice) { - - this.$util.showToast({ - title: '最低价不能大于最高价' - }); - return; - } - if (this.maxPrice != '' && Number(this.maxPrice) < Number(this.minPrice)) { - this.$util.showToast({ - title: '最高价不能小于最低价' - }); - return; - } - } - this.emptyShow = false; - this.goodsList = []; - this.$refs.mescroll.refresh(); - this.showScreen = false; - }, - //重置数据 - resetData() { - this.categoryId = 0 - this.minPrice = '' - this.maxPrice = '' - this.isFreeShipping = false - }, - goodsImg(imgStr) { - let imgs = imgStr.split(','); - return imgs[0] ? this.$util.img(imgs[0], { - size: 'mid' - }) : this.$util.getDefaultImage().goods; - }, - imgError(index) { - this.goodsList[index].goods_image = this.$util.getDefaultImage().goods; - }, - showPrice(data) { - let price = data.discount_price; - if (data.member_price && parseFloat(data.member_price) < parseFloat(price)) price = data.member_price; - return price; - }, - showMarketPrice(item) { - if (item.market_price_show) { - let price = this.showPrice(item); - if (item.market_price > 0) { - return item.market_price; - } else if (parseFloat(item.price) > parseFloat(price)) { - return item.price; - } - } - return ''; - }, - goodsTag(data) { - return data.label_name || ''; - }, - /** - * 瀑布流 - */ - waterfallflow(start = 0) { - if (!this.isList) { - //页面渲染完成后的事件 - this.$nextTick(() => { - setTimeout(() => { - let listHeight = []; - let listPosition = []; - if (start != 0) { - listHeight = this.listHeight; - listPosition = this.listPosition; - } - let column = 2; - const query = uni.createSelectorQuery().in(this); - query.selectAll('.double-column .goods-item').boundingClientRect(data => { - for (let i = start; i < data.length; i++) { - if (i < column) { - let position = {}; - position.top = uni.upx2px(20) + 'px'; - if (i % column == 0) { - position.left = data[i].width * i + "px"; - } else { - position.left = data[i].width * i + (i % column * uni - .upx2px(30)) + "px"; - } - listPosition[i] = position; - listHeight[i] = data[i].height + uni.upx2px(20); - } else { - let minHeight = Math.min(...listHeight); // 找到第一列的最小高度 - let minIndex = listHeight.findIndex(item => item === minHeight) // 找到最小高度的索引 - //设置当前子元素项的位置 - let position = {}; - position.top = minHeight + uni.upx2px(20) + "px"; - position.left = listPosition[minIndex].left; - listPosition[i] = position; - //重新定义数组最小项的高度 进行累加 - listHeight[minIndex] += data[i].height + uni.upx2px(20); - } - } - this.listHeight = listHeight; - this.listPosition = listPosition; - }).exec(); - }, 50) - }) - } - }, - getBrandList() { - var data = { - page: 1, - page_size: 0 - }; - this.$api.sendRequest({ - url: '/api/goodsbrand/page', - data: data, - success: res => { - if (res.code == 0 && res.data) { - let data = res.data; - this.brandList = data.list; - } - } - }); - }, - /** - * 添加购物车回调 - */ - addCart(id) { - }, - genNonDuplicate(len = 6) { - return Number(Math.random().toString().substr(3, len) + Date.now()).toString(36); - } - } +export default { + data() { + return { + listStyle: '', + loadingType: 'loading', //加载更多状态 + orderType: '', + priceOrder: 'desc', //1 价格从低到高 2价格从高到低 + categoryList: [], //排序类型 + goodsList: [], + order: '', + sort: 'desc', + showScreen: false, + keyword: '', + categoryId: 0, + minPrice: '', + maxPrice: '', + isFreeShipping: false, //是否免邮 + isIphoneX: false, + coupon: 0, + emptyShow: false, + isList: true, //列表样式 + //分享所需标题 + share_title: '', + //搜索到多少件商品 + count: 0, + //当前分类名称 + category_title: '', + //优惠券数据 + coupon_name: '', + //列表瀑布流数据 + listHeight: [], + listPosition: [], + debounce: null, + brandId: 0, + merch_id:0, + merch:{}, + brandList: [], //品牌筛选项 + config: { + fontWeight: false, + padding: 0, + cartEvent: "detail", + text: "购买", + textColor: "#FFFFFF", + theme: "default", + aroundRadius: 25, + control: true, + bgColor: "#FF6A00", + style: "button", + iconDiy: { + iconType: "icon", + icon: "", + style: { + fontSize: "60", + iconBgColor: [], + iconBgColorDeg: 0, + iconBgImg: "", + bgRadius: 0, + iconColor: [ + "#000000" + ], + iconColorDeg: 0 + } + } + }, + } + }, + + onLoad(options) { + this.categoryId = options.category_id || 0; + this.keyword = options.keyword || ''; + this.coupon = options.coupon || 0; + this.goods_id_arr = options.goods_id_arr || 0; + this.brandId = options.brand_id || 0; + this.merch_id = options.merch_id || 0; + if(this.merch_id > 0){ + this.getMerch() + }else{ + uni.showModal({ + title:'提示', + content:'商家不存在', + showCancel:false, + success(e){ + uni.navigateBack({}) + } + }) + } + this.loadCategoryList(this.categoryId); + this.getBrandList(); + this.isIphoneX = this.$util.uniappIsIPhoneX(); + + //小程序分享接收source_member + if (options.source_member) { + uni.setStorageSync('source_member', options.source_member); + } + // 小程序扫码进入,接收source_member + if (options.scene) { + var sceneParams = decodeURIComponent(options.scene); + sceneParams = sceneParams.split('&'); + if (sceneParams.length) { + sceneParams.forEach(item => { + if (item.indexOf('sku_id') != -1) this.skuId = item.split('-')[1]; + if (item.indexOf('m') != -1) uni.setStorageSync('source_member', item.split('-')[1]); + if (item.indexOf('is_test') != -1) uni.setStorageSync('is_test', 1); + }); + } + } + + uni.onWindowResize(res => { + if (this.debounce) clearTimeout(this.debounce); + this.waterfallflow(0); + }) + }, + onShow() { + //记录分享关系 + if (this.storeToken && uni.getStorageSync('source_member')) { + this.$util.onSourceMember(uni.getStorageSync('source_member')); + } + }, + /** + * 转发分享 + */ + onShareAppMessage(res) { + var title = '搜索到' + this.count + '件“' + this.keyword + this.category_title + this.coupon_name + '”相关的优质商品'; + let route = this.$util.getCurrentShareRoute(this.memberInfo ? this.memberInfo.member_id : 0); + var path = route.path; + return { + title: title, + path: path, + success: res => { + }, + fail: res => { + } + }; + }, + // 分享到微信朋友圈 + onShareTimeline() { + var title = '搜索到' + this.count + '件“' + this.keyword + this.category_title + this.coupon_name + '”相关的优质商品'; + let route = this.$util.getCurrentShareRoute(this.memberInfo ? this.memberInfo.member_id : 0); + var query = route.query; + return { + title: title, + query: query, + imageUrl: '' + }; + }, + methods: { + getMerch(){ + this.$api.sendRequest({ + url: '/merch/api/merch/merchinfo', + data: { + merch_id:this.merch_id + }, + success: res => { + console.log(res) + this.merch = res.data + } + }); + }, + /** + * 获取优惠券数据 + */ + couponInfo(id) { + return new Promise(resolve => { + this.$api.sendRequest({ + url: '/coupon/api/coupon/typeinfo', + data: { + coupon_type_id: id + }, + success: res => { + if (res.code >= 0) { + resolve(res.data.coupon_name); + } + } + }); + }) + }, + /** + * 获取分类名称 + */ + share_select(data, id) { + return new Promise((resolve) => { + data.forEach((item) => { + if (item.category_id == id) { + resolve(item.category_name) + } + if (item.child_list && item.child_list.length > 0) { + item.child_list.forEach((v) => { + if (v.category_id == id) { + resolve(v.category_name) + } + if (v.child_list && v.child_list.length > 0) { + v.forEach((m) => { + if (m.category_id == id) { + resolve(m.category_name) + } + }) + + } + }) + } + }) + }) + }, + //加载分类 + loadCategoryList(fid, sid) { + this.$api.sendRequest({ + url: '/api/goodscategory/tree', + data: {}, + success: res => { + if (res.data != null) { + this.categoryList = res.data + } + } + }); + }, + getGoodsList(mescroll) { + this.$api.sendRequest({ + url: '/api/goodssku/page', + data: { + page: mescroll.num, + page_size: mescroll.size, + keyword: this.keyword, + category_id: this.categoryId, + brand_id: this.brandId, + min_price: this.minPrice, + max_price: this.maxPrice, + is_free_shipping: (this.isFreeShipping ? 1 : 0), + order: this.order, + sort: this.sort, + coupon: this.coupon, + goods_id_arr: this.goods_id_arr, + merch_id:this.merch_id + }, + success: res => { + let newArr = [] + let msg = res.message; + if (res.code == 0 && res.data) { + this.count = res.data.count; + if (res.data.page_count == 0) { + this.emptyShow = true + } + newArr = res.data.list; + newArr = newArr.map(item => { + item.id = this.genNonDuplicate(); + return item; + }); + } else { + this.$util.showToast({ + title: msg + }) + } + this.category_title = ''; + this.coupon_name = ''; + if (res.data.config) this.config = res.data.config; + if (this.categoryId) { + this.share_select(this.categoryList, this.categoryId).then(resolve => { + this.category_title = resolve + }); + } + if (this.coupon) { + this.couponInfo(this.coupon).then(resolve => { + this.coupon_name = resolve + }); + } + mescroll.endSuccess(newArr.length); + //设置列表数据 + if (mescroll.num == 1) this.goodsList = []; //如果是第一页需手动制空列表 + this.goodsList = this.goodsList.concat(newArr); //追加新数据 + if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); + + this.waterfallflow((mescroll.num - 1) * 10); + }, + fail: res => { + //联网失败的回调 + mescroll.endErr(); + if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); + } + }); + }, + changeListStyle() { + this.isList = !this.isList; + this.waterfallflow(0); + }, + //筛选点击 + sortTabClick(tag) { + if (tag == 'sale_num') { + this.order = 'sale_num'; + this.sort = 'desc'; + } else if (tag == 'discount_price') { + this.order = 'discount_price'; + this.sort = 'desc'; + } else if (tag == 'screen') { + //筛选 + this.showScreen = true; + return; + } else { + this.order = ''; + this.sort = ''; + } + + if (this.orderType === tag && tag !== 'discount_price') return; + + this.orderType = tag; + if (tag === 'discount_price') { + this.priceOrder = this.priceOrder === 'asc' ? 'desc' : 'asc'; + this.sort = this.priceOrder; + } else { + this.priceOrder = ''; + } + this.emptyShow = false; + this.goodsList = []; + this.$refs.mescroll.refresh(); + }, + //商品详情 + toDetail(item) { + this.$util.redirectTo('/pages_goods/detail', { + goods_id: item.goods_id + }); + }, + search() { + this.emptyShow = false; + this.goodsList = []; + this.$refs.mescroll.refresh(); + }, + selectedCategory(categoryId) { + this.categoryId = categoryId; + }, + screenData() { + if (this.minPrice != '' || this.maxPrice != '') { + // if (!Number(this.minPrice) && this.minPrice) { + // this.$util.showToast({ + // title: '请输入最低价' + // }); + // return; + // } + if (!Number(this.maxPrice) && this.maxPrice) { + this.$util.showToast({ + title: '请输入最高价' + }); + return; + } + if (Number(this.minPrice) < 0 || Number(this.maxPrice) < 0) { + this.$util.showToast({ + title: '筛选价格不能小于0' + }); + return; + } + if (this.minPrice != '' && Number(this.minPrice) > Number(this.maxPrice) && this.maxPrice) { + + this.$util.showToast({ + title: '最低价不能大于最高价' + }); + return; + } + if (this.maxPrice != '' && Number(this.maxPrice) < Number(this.minPrice)) { + this.$util.showToast({ + title: '最高价不能小于最低价' + }); + return; + } + } + this.emptyShow = false; + this.goodsList = []; + this.$refs.mescroll.refresh(); + this.showScreen = false; + }, + //重置数据 + resetData() { + this.categoryId = 0 + this.minPrice = '' + this.maxPrice = '' + this.isFreeShipping = false + }, + goodsImg(imgStr) { + let imgs = imgStr.split(','); + return imgs[0] ? this.$util.img(imgs[0], { + size: 'mid' + }) : this.$util.getDefaultImage().goods; + }, + imgError(index) { + this.goodsList[index].goods_image = this.$util.getDefaultImage().goods; + }, + showPrice(data) { + let price = data.discount_price; + if (data.member_price && parseFloat(data.member_price) < parseFloat(price)) price = data.member_price; + return price; + }, + showMarketPrice(item) { + if (item.market_price_show) { + let price = this.showPrice(item); + if (item.market_price > 0) { + return item.market_price; + } else if (parseFloat(item.price) > parseFloat(price)) { + return item.price; + } + } + return ''; + }, + goodsTag(data) { + return data.label_name || ''; + }, + /** + * 瀑布流 + */ + waterfallflow(start = 0) { + if (!this.isList) { + //页面渲染完成后的事件 + this.$nextTick(() => { + setTimeout(() => { + let listHeight = []; + let listPosition = []; + if (start != 0) { + listHeight = this.listHeight; + listPosition = this.listPosition; + } + let column = 2; + const query = uni.createSelectorQuery().in(this); + query.selectAll('.double-column .goods-item').boundingClientRect(data => { + for (let i = start; i < data.length; i++) { + if (i < column) { + let position = {}; + position.top = uni.upx2px(20) + 'px'; + if (i % column == 0) { + position.left = data[i].width * i + "px"; + } else { + position.left = data[i].width * i + (i % column * uni + .upx2px(30)) + "px"; + } + listPosition[i] = position; + listHeight[i] = data[i].height + uni.upx2px(20); + } else { + let minHeight = Math.min(...listHeight); // 找到第一列的最小高度 + let minIndex = listHeight.findIndex(item => item === minHeight) // 找到最小高度的索引 + //设置当前子元素项的位置 + let position = {}; + position.top = minHeight + uni.upx2px(20) + "px"; + position.left = listPosition[minIndex].left; + listPosition[i] = position; + //重新定义数组最小项的高度 进行累加 + listHeight[minIndex] += data[i].height + uni.upx2px(20); + } + } + this.listHeight = listHeight; + this.listPosition = listPosition; + }).exec(); + }, 50) + }) + } + }, + getBrandList() { + var data = { + page: 1, + page_size: 0 + }; + this.$api.sendRequest({ + url: '/api/goodsbrand/page', + data: data, + success: res => { + if (res.code == 0 && res.data) { + let data = res.data; + this.brandList = data.list; + } + } + }); + }, + /** + * 添加购物车回调 + */ + addCart(id) { + }, + genNonDuplicate(len = 6) { + return Number(Math.random().toString().substr(3, len) + Date.now()).toString(36); + } + } } \ No newline at end of file diff --git a/pages_promotion/point/goods_list.vue b/pages_promotion/point/goods_list.vue index 725c3b6..d1e2fb1 100644 --- a/pages_promotion/point/goods_list.vue +++ b/pages_promotion/point/goods_list.vue @@ -4,9 +4,9 @@ - - - + + + diff --git a/pages_promotion/point/order_list.vue b/pages_promotion/point/order_list.vue index 82402e9..15ca50a 100644 --- a/pages_promotion/point/order_list.vue +++ b/pages_promotion/point/order_list.vue @@ -206,17 +206,17 @@ if (item.type == 1 && item.relate_order_id) { switch (item.delivery_type) { case 'store': - this.$util.redirectTo('/pages/order/detail_pickup', { + this.$util.redirectTo('/pages_order/detail_pickup', { order_id: item.relate_order_id }); break; case 'local': - this.$util.redirectTo('/pages/order/detail_local_delivery', { + this.$util.redirectTo('/pages_order/detail_local_delivery', { order_id: item.relate_order_id }); break; case 'express': - this.$util.redirectTo('/pages/order/detail', { + this.$util.redirectTo('/pages_order/detail', { order_id: item.relate_order_id }); break; @@ -226,7 +226,7 @@ }); } } else { - this.$util.redirectTo('/pages/order/detail_point', { + this.$util.redirectTo('/pages_order/detail_point', { order_id: item.order_id }); } diff --git a/pages_promotion/point/public/js/payment.js b/pages_promotion/point/public/js/payment.js index 9260bdf..c06528b 100644 --- a/pages_promotion/point/public/js/payment.js +++ b/pages_promotion/point/public/js/payment.js @@ -1,581 +1,581 @@ -export default { - data() { - return { - isIphoneX: false, - orderCreateData: { - member_address: { - name: '', - mobile: '' - } - }, - orderPaymentData: { - exchange_info: { - type: 0 - }, - delivery: { - delivery_type: '', - express_type: [], - member_address: { - name: '', - mobile: '' - }, - local: { - info: { - start_time: 0, - end_time: 0, - time_week: [] - } - }, - }, - }, - isSub: false, - tempData: null, - // 门店信息 - storeInfo: { - storeList: [], //门店列表 - currStore: {} //当前选择门店 - }, - // 自提地址 - member_address: { - name: '', - mobile: '' - }, - // 当前时间 - timeInfo: { - week: 0, - start_time: 0, - end_time: 0, - showTime: false, - showTimeBar: false - }, - deliveryWeek: "", - // 选择自提、配送防重判断 - judge: true, - menuButtonBounding: {} - }; - }, - methods: { - // 显示弹出层 - openPopup(ref) { - this.$refs[ref].open(); - }, - // 关闭弹出层 - closePopup(ref) { - if (this.tempData) { - Object.assign(this.orderCreateData, this.tempData); - Object.assign(this.orderPaymentData, this.tempData); - this.tempData = null; - this.$forceUpdate(); - } - this.$refs[ref].close(); - }, - // 选择收货地址 - selectAddress() { - var params = { - back: '/pages_promotion/point/payment', - local: 0, - type: 1 - } - // 外卖配送需要定位地址 - if (this.orderPaymentData.delivery.delivery_type == 'local') { - params.local = 1; - params.type = 2; - } - this.$util.redirectTo('/pages_tool/member/address', params); - }, - // 获取订单初始化数据 - getOrderPaymentData() { - this.orderCreateData = uni.getStorageSync('exchangeOrderCreateData'); - var pay_flag = uni.getStorageSync("pay_flag"); // 支付中标识,防止返回时,提示,跳转错误 - if (!this.orderCreateData) { - if (pay_flag == 1) { - uni.removeStorageSync("pay_flag"); - } else { - this.$util.showToast({ - title: '未获取到创建订单所需数据!' - }); - setTimeout(() => { - this.$util.redirectTo('/pages/index/index'); - }, 1500); - } - return; - } - - // 获取经纬度 - if (this.location) { - this.orderCreateData.latitude = this.location.latitude; - this.orderCreateData.longitude = this.location.longitude; - } - - this.$api.sendRequest({ - url: '/pointexchange/api/ordercreate/payment', - data: this.orderCreateData, - success: res => { - if (res.code >= 0) { - this.orderPaymentData = res.data; - this.orderPaymentData.timestamp = res.timestamp; - - this.handlePaymentData(); - if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); - } else { - this.$util.showToast({ - title: '未获取到创建订单所需数据!' - }); - setTimeout(() => { - this.$util.redirectTo('/pages/index/index'); - }, 1500); - } - }, - fail: res => { - if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); - } - }) - }, - // 处理结算订单数据 - handlePaymentData() { - this.orderCreateData.delivery = {}; - this.orderCreateData.buyer_message = ''; - - var data = JSON.parse(JSON.stringify(this.orderPaymentData)); - this.orderCreateData.order_key = data.order_key; - - this.orderCreateData.delivery.store_id = 0; - this.orderCreateData.member_address = data.delivery.member_address; - - // 店铺配送方式 - if (data.delivery.express_type != undefined && data.delivery.express_type[0] != undefined) { - - let deliveryStorage = uni.getStorageSync('delivery'); - let delivery = data.delivery.express_type[0]; - data.delivery.express_type.forEach(item => { - if (deliveryStorage && item.name == deliveryStorage.delivery_type) { - delivery = item; - } - }); - - this.selectDeliveryType(delivery); - - } - - if (this.orderPaymentData.is_virtual) this.orderCreateData.member_address = { - mobile: data.member_account.mobile != '' ? data.member_account.mobile : '' - }; - - // Object.assign(this.orderPaymentData, this.orderCreateData); - this.orderCalculate(); - }, - // 转化时间字符串 - getTimeStr(val) { - var h = parseInt(val / 3600).toString(); - var m = parseInt((val % 3600) / 60).toString(); - if (m.length == 1) { - m = '0' + m; - } - if (h.length == 1) { - h = '0' + h; - } - return h + ':' + m; - }, - // 订单计算 - orderCalculate() { - var data = this.$util.deepClone(this.orderCreateData); - data.delivery = JSON.stringify(data.delivery); - if (this.orderCreateData.delivery.delivery_type == 'store') { - data.member_address = JSON.stringify(this.member_address); - } else { - data.member_address = JSON.stringify(data.member_address); - } - - this.$api.sendRequest({ - url: '/pointexchange/api/ordercreate/calculate', - data, - success: res => { - if (res.code >= 0) { - this.orderPaymentData.member_address = res.data.member_address; - this.orderPaymentData.delivery_money = res.data.delivery_money; - this.orderPaymentData.order_money = res.data.order_money; - - Object.assign(this.orderPaymentData.delivery, res.data.delivery); - - if (res.data.local_config) this.orderPaymentData.local_config = res.data - .config.local; - - //时间选择判断 - if (res.data.delivery.delivery_store_info) { - this.orderPaymentData.delivery_store_info = JSON.parse(res.data.delivery.delivery_store_info); - if (this.judge) { - if (this.orderPaymentData.delivery.delivery_type == "store") { - this.storetime('no'); - } else if (this.orderPaymentData.delivery.delivery_type == 'local') { - this.localtime('no'); - } - this.judge = false; - } - } - - this.createBtn(); - this.$forceUpdate(); - } else { - this.$util.showToast({ - title: res.message - }); - } - }, - }) - }, - /** - * 订单创建验证 - */ - createBtn() { - if (this.orderPaymentData.delivery && - this.orderPaymentData.delivery.delivery_type == 'local' && - this.orderPaymentData.delivery && - this.orderPaymentData.delivery.error && - this.orderPaymentData.delivery.start_money > this.orderPaymentData.price) { - return false; - } - if (this.orderPaymentData.delivery && - this.orderPaymentData.delivery.delivery_type == 'local' && - this.orderPaymentData.delivery && - this.orderPaymentData.delivery.error && - this.orderPaymentData.delivery.error !== '') { - return false; - } - return true; - }, - // 订单创建 - orderCreate() { - if (this.verify()) { - if (this.isSub) return; - this.isSub = true; - - uni.setStorageSync('paySource', 'pointexchange'); - - var data = this.$util.deepClone(this.orderCreateData); - data.delivery = JSON.stringify(data.delivery); - if (this.orderCreateData.delivery.delivery_type == 'store') { - data.member_address = JSON.stringify(this.member_address); - } else { - data.member_address = JSON.stringify(data.member_address); - } - - this.$api.sendRequest({ - url: '/pointexchange/api/ordercreate/create', - data, - success: res => { - uni.hideLoading(); - if (res.code >= 0) { - if (this.orderPaymentData.exchange_info.type == 1 && this.orderPaymentData.order_money != '0.00') { - - let orderCreateData = uni.getStorageSync('exchangeOrderCreateData'); - orderCreateData.out_trade_no = res.data; - uni.setStorageSync('exchangeOrderCreateData', orderCreateData); - - this.$refs.choosePaymentPopup.getPayInfo(res.data); - this.isSub = false; - } else { - this.$util.redirectTo('/pages_promotion/point/result', {}, 'redirectTo'); - } - } else { - this.isSub = false; - if (res.data.error_code == 10 || res.data.error_code == 12) { - uni.showModal({ - title: '订单未创建', - content: res.message, - confirmText: '去设置', - success: res => { - if (res.confirm) { - this.selectAddress(); - } - } - }) - } else { - this.$util.showToast({ - title: res.message - }); - } - } - }, - fail: res => { - uni.hideLoading(); - this.isSub = false; - } - }) - } - }, - // 订单验证 - verify() { - if (this.orderPaymentData.exchange_info.type == 1) { - if (this.orderPaymentData.is_virtual == 1) { - if (!this.orderCreateData.member_address.mobile.length) { - this.$util.showToast({ - title: '请输入您的手机号码' - }); - return false; - } - if (!this.$util.verifyMobile(this.orderCreateData.member_address.mobile)) { - this.$util.showToast({ - title: '请输入正确的手机号码' - }); - return false; - } - } - - if (this.orderPaymentData.is_virtual == 0) { - if (!this.orderCreateData.delivery || !this.orderCreateData.delivery.delivery_type) { - this.$util.showToast({ - title: '商家未设置配送方式' - }); - return false; - } - - if (this.orderCreateData.delivery.delivery_type != 'store') { - if (!this.orderCreateData.member_address) { - this.$util.showToast({ - title: '请先选择您的收货地址' - }); - return false; - } - } - - if (this.orderCreateData.delivery.delivery_type == 'store') { - if (!this.orderCreateData.delivery.store_id) { - this.$util.showToast({ - title: '没有可提货的门店,请选择其他配送方式' - }); - return false; - } - if (!this.member_address.mobile) { - this.$util.showToast({ - title: '请输入预留手机' - }); - return false; - } - if (!this.$util.verifyMobile(this.member_address.mobile)) { - this.$util.showToast({ - title: '请输入正确的预留手机' - }); - return false; - } - - if (!this.orderCreateData.delivery.buyer_ask_delivery_time.start_date || !this.orderCreateData.delivery.buyer_ask_delivery_time.end_date) { - this.$util.showToast({ - title: '请选择自提时间' - }); - return false; - } - } - - if (this.orderCreateData.delivery.delivery_type == 'local') { - if (!this.orderCreateData.delivery.store_id) { - this.$util.showToast({ - title: '没有可配送的门店,请选择其他配送方式' - }); - return false; - } - if (this.orderPaymentData.config.local.is_use && this.orderPaymentData.delivery.local.info && this.orderPaymentData.delivery.local.info.time_is_open == 1 && (!this.orderCreateData.delivery.buyer_ask_delivery_time.start_date || !this.orderCreateData.delivery.buyer_ask_delivery_time.end_date)) { - this.$util.showToast({ - title: '请选择配送时间' - }); - return false; - } - } - } - - } - return true; - }, - // 显示店铺配送信息 - openSiteDelivery() { - this.tempData = { - delivery: this.$util.deepClone(this.orderPaymentData.delivery) - }; - this.$refs.deliveryPopup.open(); - }, - // 选择配送方式 - selectDeliveryType(data) { - uni.setStorageSync('delivery', { - delivery_type: data.name, - delivery_type_name: data.title - }); - this.orderCreateData.delivery.delivery_type = data.name; - this.orderCreateData.delivery.delivery_type_name = data.title; - - // 如果是门店配送 - if (data.name == 'store') { - this.storeSelected(data); - this.member_address.name = this.orderPaymentData.member_account.nickname; - if (!this.member_address.mobile) this.member_address.mobile = this.orderPaymentData.member_account.mobile != '' ? this.orderPaymentData.member_account.mobile : ''; - } - if (data.name == 'local') { - this.storeSelected(data); - } - // Object.assign(this.orderPaymentData, this.orderCreateData); - - this.judge = true; - - this.orderCalculate(); - this.$forceUpdate(); - }, - // 切换到门店 - storeSelected(data) { - // 门店列表 - this.storeInfo.storeList = data.store_list; - let store = data.store_list[0] ? data.store_list[0] : null; - this.selectPickupPoint(store); - }, - // 选择自提点 - selectPickupPoint(store_item) { - if (store_item) { - this.orderCreateData.delivery.store_id = store_item.store_id; - this.storeInfo.currStore = store_item; - // 存储所选门店 - let delivery = uni.getStorageSync('delivery') || { - name: this.orderCreateData.delivery.delivery_type, - title: this.orderCreateData.delivery.delivery_type_name - }; - delivery.store_id = store_item.store_id; - uni.setStorageSync('delivery', delivery) - } else { - this.orderCreateData.delivery.store_id = 0; - this.storeInfo.currStore = {}; - } - this.orderCreateData.delivery.buyer_ask_delivery_time = { - start_date: '', - end_date: '' - }; - this.orderCreateData.buyer_ask_delivery_title = ''; - // Object.assign(this.orderPaymentData, this.orderCreateData); - this.orderCalculate(); - this.$forceUpdate(); - this.$refs['deliveryPopup'].close(); - }, - imageError() { - let imageUrl = '' - if (this.orderPaymentData.exchange_info.type == 1) { - imageUrl = this.$util.img('public/uniapp/point/gift.png'); - } else if (this.orderPaymentData.exchange_info.type == 2) { - imageUrl = this.$util.img('public/uniapp/point/coupon.png'); - } else if (this.orderPaymentData.exchange_info.type == 3) { - imageUrl = this.$util.img('public/uniapp/point/hongbao.png'); - } else { - imageUrl = this.$util.getDefaultImage().goods; - } - this.orderPaymentData.exchange_info.image = imageUrl; - this.$forceUpdate(); - }, - // 获取时间 - getTime() { - // 必须是字符串,跟后端一致 - let weeks = ['0', '1', '2', '3', '4', '5', '6']; - let week = new Date().getDay(); - this.timeInfo.week = weeks[week]; - }, - navigateTo(sku_id) { - this.$util.redirectTo('/pages/goods/detail', { - sku_id - }); - }, - // 显示选择支付方式弹框 - openChoosePayment() { - if (this.verify() && this.orderPaymentData.exchange_info.type == 1 && this.orderPaymentData.order_money != '0.00') this.$refs.choosePaymentPopup.open(); - else this.orderCreate(); - }, - /** - * 同城配送数据处理 - */ - localtime(type = '') { - let data = this.$util.deepClone(this.orderPaymentData.delivery.local.info); - if (data.delivery_time) { - data.end_time = data.delivery_time[(data.delivery_time.length - 1)].end_time; - } - let obj = { - delivery: this.orderCreateData.delivery, - dataTime: data - } - this.$refs.TimePopup.open(obj, type); - }, - /** - * 门店自提数据处理 - */ - storetime(type = '') { - if (this.orderPaymentData.delivery.delivery_store_info) { - let data = this.$util.deepClone(this.storeInfo.currStore); - data.delivery_time = typeof data.delivery_time == 'string' && data.delivery_time ? JSON.parse(data - .delivery_time) : data.delivery_time; - if (!data.delivery_time || data.delivery_time.length == undefined && !data.delivery_time.length) { - data.delivery_time = [{ - start_time: data.start_time, - end_time: data.end_time - }] - } - let obj = { - delivery: this.orderCreateData.delivery, - dataTime: data - } - this.$refs.TimePopup.open(obj, type); - this.$forceUpdate(); - } - }, - /** - * 弹窗返回数据 - */ - selectTime(data) { - if (data.data && data.data.month) { - this.orderCreateData.delivery.buyer_ask_delivery_time = { - start_date:data.data.start_date, - end_date:data.data.end_date - }; - if (data.data.title == '今天' || data.data.title == '明天') { - this.orderCreateData.buyer_ask_delivery_title = data.data.title + '(' + data.data.time + ')' - } else { - this.orderCreateData.buyer_ask_delivery_title = data.data.month + '(' + data.data.time + ')' - } - this.orderCalculate(); - this.$forceUpdate(); - } - }, - back() { - uni.navigateBack({ - delta: 1 - }); - } - }, - onShow() { - if (uni.getStorageSync('addressBack')) { - uni.removeStorageSync('addressBack'); - } - // 判断登录 - if (!this.storeToken) { - this.$util.redirectTo('/pages_tool/login/login'); - } else { - this.getOrderPaymentData(); - } - this.judge = true; - - this.getTime(); - this.isIphoneX = this.$util.uniappIsIPhoneX() - }, - onHide() { - if (this.$refs.loadingCover) this.$refs.loadingCover.show(); - }, - onLoad() { - if (!this.location) this.$util.getLocation(); - // #ifdef MP - this.menuButtonBounding = uni.getMenuButtonBoundingClientRect(); - // #endif - }, - watch: { - location: function(nVal) { - if (nVal) { - this.getOrderPaymentData(); - } - } - }, - filters: { - // 金额格式化输出 - moneyFormat(money) { - return parseFloat(money).toFixed(2); - } - } +export default { + data() { + return { + isIphoneX: false, + orderCreateData: { + member_address: { + name: '', + mobile: '' + } + }, + orderPaymentData: { + exchange_info: { + type: 0 + }, + delivery: { + delivery_type: '', + express_type: [], + member_address: { + name: '', + mobile: '' + }, + local: { + info: { + start_time: 0, + end_time: 0, + time_week: [] + } + }, + }, + }, + isSub: false, + tempData: null, + // 门店信息 + storeInfo: { + storeList: [], //门店列表 + currStore: {} //当前选择门店 + }, + // 自提地址 + member_address: { + name: '', + mobile: '' + }, + // 当前时间 + timeInfo: { + week: 0, + start_time: 0, + end_time: 0, + showTime: false, + showTimeBar: false + }, + deliveryWeek: "", + // 选择自提、配送防重判断 + judge: true, + menuButtonBounding: {} + }; + }, + methods: { + // 显示弹出层 + openPopup(ref) { + this.$refs[ref].open(); + }, + // 关闭弹出层 + closePopup(ref) { + if (this.tempData) { + Object.assign(this.orderCreateData, this.tempData); + Object.assign(this.orderPaymentData, this.tempData); + this.tempData = null; + this.$forceUpdate(); + } + this.$refs[ref].close(); + }, + // 选择收货地址 + selectAddress() { + var params = { + back: '/pages_promotion/point/payment', + local: 0, + type: 1 + } + // 外卖配送需要定位地址 + if (this.orderPaymentData.delivery.delivery_type == 'local') { + params.local = 1; + params.type = 2; + } + this.$util.redirectTo('/pages_tool/member/address', params); + }, + // 获取订单初始化数据 + getOrderPaymentData() { + this.orderCreateData = uni.getStorageSync('exchangeOrderCreateData'); + var pay_flag = uni.getStorageSync("pay_flag"); // 支付中标识,防止返回时,提示,跳转错误 + if (!this.orderCreateData) { + if (pay_flag == 1) { + uni.removeStorageSync("pay_flag"); + } else { + this.$util.showToast({ + title: '未获取到创建订单所需数据!' + }); + setTimeout(() => { + this.$util.redirectTo('/pages/index/index'); + }, 1500); + } + return; + } + + // 获取经纬度 + if (this.location) { + this.orderCreateData.latitude = this.location.latitude; + this.orderCreateData.longitude = this.location.longitude; + } + + this.$api.sendRequest({ + url: '/pointexchange/api/ordercreate/payment', + data: this.orderCreateData, + success: res => { + if (res.code >= 0) { + this.orderPaymentData = res.data; + this.orderPaymentData.timestamp = res.timestamp; + + this.handlePaymentData(); + if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); + } else { + this.$util.showToast({ + title: '未获取到创建订单所需数据!' + }); + setTimeout(() => { + this.$util.redirectTo('/pages/index/index'); + }, 1500); + } + }, + fail: res => { + if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); + } + }) + }, + // 处理结算订单数据 + handlePaymentData() { + this.orderCreateData.delivery = {}; + this.orderCreateData.buyer_message = ''; + + var data = JSON.parse(JSON.stringify(this.orderPaymentData)); + this.orderCreateData.order_key = data.order_key; + + this.orderCreateData.delivery.store_id = 0; + this.orderCreateData.member_address = data.delivery.member_address; + + // 店铺配送方式 + if (data.delivery.express_type != undefined && data.delivery.express_type[0] != undefined) { + + let deliveryStorage = uni.getStorageSync('delivery'); + let delivery = data.delivery.express_type[0]; + data.delivery.express_type.forEach(item => { + if (deliveryStorage && item.name == deliveryStorage.delivery_type) { + delivery = item; + } + }); + + this.selectDeliveryType(delivery); + + } + + if (this.orderPaymentData.is_virtual) this.orderCreateData.member_address = { + mobile: data.member_account.mobile != '' ? data.member_account.mobile : '' + }; + + // Object.assign(this.orderPaymentData, this.orderCreateData); + this.orderCalculate(); + }, + // 转化时间字符串 + getTimeStr(val) { + var h = parseInt(val / 3600).toString(); + var m = parseInt((val % 3600) / 60).toString(); + if (m.length == 1) { + m = '0' + m; + } + if (h.length == 1) { + h = '0' + h; + } + return h + ':' + m; + }, + // 订单计算 + orderCalculate() { + var data = this.$util.deepClone(this.orderCreateData); + data.delivery = JSON.stringify(data.delivery); + if (this.orderCreateData.delivery.delivery_type == 'store') { + data.member_address = JSON.stringify(this.member_address); + } else { + data.member_address = JSON.stringify(data.member_address); + } + + this.$api.sendRequest({ + url: '/pointexchange/api/ordercreate/calculate', + data, + success: res => { + if (res.code >= 0) { + this.orderPaymentData.member_address = res.data.member_address; + this.orderPaymentData.delivery_money = res.data.delivery_money; + this.orderPaymentData.order_money = res.data.order_money; + + Object.assign(this.orderPaymentData.delivery, res.data.delivery); + + if (res.data.local_config) this.orderPaymentData.local_config = res.data + .config.local; + + //时间选择判断 + if (res.data.delivery.delivery_store_info) { + this.orderPaymentData.delivery_store_info = JSON.parse(res.data.delivery.delivery_store_info); + if (this.judge) { + if (this.orderPaymentData.delivery.delivery_type == "store") { + this.storetime('no'); + } else if (this.orderPaymentData.delivery.delivery_type == 'local') { + this.localtime('no'); + } + this.judge = false; + } + } + + this.createBtn(); + this.$forceUpdate(); + } else { + this.$util.showToast({ + title: res.message + }); + } + }, + }) + }, + /** + * 订单创建验证 + */ + createBtn() { + if (this.orderPaymentData.delivery && + this.orderPaymentData.delivery.delivery_type == 'local' && + this.orderPaymentData.delivery && + this.orderPaymentData.delivery.error && + this.orderPaymentData.delivery.start_money > this.orderPaymentData.price) { + return false; + } + if (this.orderPaymentData.delivery && + this.orderPaymentData.delivery.delivery_type == 'local' && + this.orderPaymentData.delivery && + this.orderPaymentData.delivery.error && + this.orderPaymentData.delivery.error !== '') { + return false; + } + return true; + }, + // 订单创建 + orderCreate() { + if (this.verify()) { + if (this.isSub) return; + this.isSub = true; + + uni.setStorageSync('paySource', 'pointexchange'); + + var data = this.$util.deepClone(this.orderCreateData); + data.delivery = JSON.stringify(data.delivery); + if (this.orderCreateData.delivery.delivery_type == 'store') { + data.member_address = JSON.stringify(this.member_address); + } else { + data.member_address = JSON.stringify(data.member_address); + } + + this.$api.sendRequest({ + url: '/pointexchange/api/ordercreate/create', + data, + success: res => { + uni.hideLoading(); + if (res.code >= 0) { + if (this.orderPaymentData.exchange_info.type == 1 && this.orderPaymentData.order_money != '0.00') { + + let orderCreateData = uni.getStorageSync('exchangeOrderCreateData'); + orderCreateData.out_trade_no = res.data; + uni.setStorageSync('exchangeOrderCreateData', orderCreateData); + + this.$refs.choosePaymentPopup.getPayInfo(res.data); + this.isSub = false; + } else { + this.$util.redirectTo('/pages_promotion/point/result', {}, 'redirectTo'); + } + } else { + this.isSub = false; + if (res.data.error_code == 10 || res.data.error_code == 12) { + uni.showModal({ + title: '订单未创建', + content: res.message, + confirmText: '去设置', + success: res => { + if (res.confirm) { + this.selectAddress(); + } + } + }) + } else { + this.$util.showToast({ + title: res.message + }); + } + } + }, + fail: res => { + uni.hideLoading(); + this.isSub = false; + } + }) + } + }, + // 订单验证 + verify() { + if (this.orderPaymentData.exchange_info.type == 1) { + if (this.orderPaymentData.is_virtual == 1) { + if (!this.orderCreateData.member_address.mobile.length) { + this.$util.showToast({ + title: '请输入您的手机号码' + }); + return false; + } + if (!this.$util.verifyMobile(this.orderCreateData.member_address.mobile)) { + this.$util.showToast({ + title: '请输入正确的手机号码' + }); + return false; + } + } + + if (this.orderPaymentData.is_virtual == 0) { + if (!this.orderCreateData.delivery || !this.orderCreateData.delivery.delivery_type) { + this.$util.showToast({ + title: '商家未设置配送方式' + }); + return false; + } + + if (this.orderCreateData.delivery.delivery_type != 'store') { + if (!this.orderCreateData.member_address) { + this.$util.showToast({ + title: '请先选择您的收货地址' + }); + return false; + } + } + + if (this.orderCreateData.delivery.delivery_type == 'store') { + if (!this.orderCreateData.delivery.store_id) { + this.$util.showToast({ + title: '没有可提货的门店,请选择其他配送方式' + }); + return false; + } + if (!this.member_address.mobile) { + this.$util.showToast({ + title: '请输入预留手机' + }); + return false; + } + if (!this.$util.verifyMobile(this.member_address.mobile)) { + this.$util.showToast({ + title: '请输入正确的预留手机' + }); + return false; + } + + if (!this.orderCreateData.delivery.buyer_ask_delivery_time.start_date || !this.orderCreateData.delivery.buyer_ask_delivery_time.end_date) { + this.$util.showToast({ + title: '请选择自提时间' + }); + return false; + } + } + + if (this.orderCreateData.delivery.delivery_type == 'local') { + if (!this.orderCreateData.delivery.store_id) { + this.$util.showToast({ + title: '没有可配送的门店,请选择其他配送方式' + }); + return false; + } + if (this.orderPaymentData.config.local.is_use && this.orderPaymentData.delivery.local.info && this.orderPaymentData.delivery.local.info.time_is_open == 1 && (!this.orderCreateData.delivery.buyer_ask_delivery_time.start_date || !this.orderCreateData.delivery.buyer_ask_delivery_time.end_date)) { + this.$util.showToast({ + title: '请选择配送时间' + }); + return false; + } + } + } + + } + return true; + }, + // 显示店铺配送信息 + openSiteDelivery() { + this.tempData = { + delivery: this.$util.deepClone(this.orderPaymentData.delivery) + }; + this.$refs.deliveryPopup.open(); + }, + // 选择配送方式 + selectDeliveryType(data) { + uni.setStorageSync('delivery', { + delivery_type: data.name, + delivery_type_name: data.title + }); + this.orderCreateData.delivery.delivery_type = data.name; + this.orderCreateData.delivery.delivery_type_name = data.title; + + // 如果是门店配送 + if (data.name == 'store') { + this.storeSelected(data); + this.member_address.name = this.orderPaymentData.member_account.nickname; + if (!this.member_address.mobile) this.member_address.mobile = this.orderPaymentData.member_account.mobile != '' ? this.orderPaymentData.member_account.mobile : ''; + } + if (data.name == 'local') { + this.storeSelected(data); + } + // Object.assign(this.orderPaymentData, this.orderCreateData); + + this.judge = true; + + this.orderCalculate(); + this.$forceUpdate(); + }, + // 切换到门店 + storeSelected(data) { + // 门店列表 + this.storeInfo.storeList = data.store_list; + let store = data.store_list[0] ? data.store_list[0] : null; + this.selectPickupPoint(store); + }, + // 选择自提点 + selectPickupPoint(store_item) { + if (store_item) { + this.orderCreateData.delivery.store_id = store_item.store_id; + this.storeInfo.currStore = store_item; + // 存储所选门店 + let delivery = uni.getStorageSync('delivery') || { + name: this.orderCreateData.delivery.delivery_type, + title: this.orderCreateData.delivery.delivery_type_name + }; + delivery.store_id = store_item.store_id; + uni.setStorageSync('delivery', delivery) + } else { + this.orderCreateData.delivery.store_id = 0; + this.storeInfo.currStore = {}; + } + this.orderCreateData.delivery.buyer_ask_delivery_time = { + start_date: '', + end_date: '' + }; + this.orderCreateData.buyer_ask_delivery_title = ''; + // Object.assign(this.orderPaymentData, this.orderCreateData); + this.orderCalculate(); + this.$forceUpdate(); + this.$refs['deliveryPopup'].close(); + }, + imageError() { + let imageUrl = '' + if (this.orderPaymentData.exchange_info.type == 1) { + imageUrl = this.$util.img('public/uniapp/point/gift.png'); + } else if (this.orderPaymentData.exchange_info.type == 2) { + imageUrl = this.$util.img('public/uniapp/point/coupon.png'); + } else if (this.orderPaymentData.exchange_info.type == 3) { + imageUrl = this.$util.img('public/uniapp/point/hongbao.png'); + } else { + imageUrl = this.$util.getDefaultImage().goods; + } + this.orderPaymentData.exchange_info.image = imageUrl; + this.$forceUpdate(); + }, + // 获取时间 + getTime() { + // 必须是字符串,跟后端一致 + let weeks = ['0', '1', '2', '3', '4', '5', '6']; + let week = new Date().getDay(); + this.timeInfo.week = weeks[week]; + }, + navigateTo(sku_id) { + this.$util.redirectTo('/pages_goods/detail', { + sku_id + }); + }, + // 显示选择支付方式弹框 + openChoosePayment() { + if (this.verify() && this.orderPaymentData.exchange_info.type == 1 && this.orderPaymentData.order_money != '0.00') this.$refs.choosePaymentPopup.open(); + else this.orderCreate(); + }, + /** + * 同城配送数据处理 + */ + localtime(type = '') { + let data = this.$util.deepClone(this.orderPaymentData.delivery.local.info); + if (data.delivery_time) { + data.end_time = data.delivery_time[(data.delivery_time.length - 1)].end_time; + } + let obj = { + delivery: this.orderCreateData.delivery, + dataTime: data + } + this.$refs.TimePopup.open(obj, type); + }, + /** + * 门店自提数据处理 + */ + storetime(type = '') { + if (this.orderPaymentData.delivery.delivery_store_info) { + let data = this.$util.deepClone(this.storeInfo.currStore); + data.delivery_time = typeof data.delivery_time == 'string' && data.delivery_time ? JSON.parse(data + .delivery_time) : data.delivery_time; + if (!data.delivery_time || data.delivery_time.length == undefined && !data.delivery_time.length) { + data.delivery_time = [{ + start_time: data.start_time, + end_time: data.end_time + }] + } + let obj = { + delivery: this.orderCreateData.delivery, + dataTime: data + } + this.$refs.TimePopup.open(obj, type); + this.$forceUpdate(); + } + }, + /** + * 弹窗返回数据 + */ + selectTime(data) { + if (data.data && data.data.month) { + this.orderCreateData.delivery.buyer_ask_delivery_time = { + start_date:data.data.start_date, + end_date:data.data.end_date + }; + if (data.data.title == '今天' || data.data.title == '明天') { + this.orderCreateData.buyer_ask_delivery_title = data.data.title + '(' + data.data.time + ')' + } else { + this.orderCreateData.buyer_ask_delivery_title = data.data.month + '(' + data.data.time + ')' + } + this.orderCalculate(); + this.$forceUpdate(); + } + }, + back() { + uni.navigateBack({ + delta: 1 + }); + } + }, + onShow() { + if (uni.getStorageSync('addressBack')) { + uni.removeStorageSync('addressBack'); + } + // 判断登录 + if (!this.storeToken) { + this.$util.redirectTo('/pages_tool/login/login'); + } else { + this.getOrderPaymentData(); + } + this.judge = true; + + this.getTime(); + this.isIphoneX = this.$util.uniappIsIPhoneX() + }, + onHide() { + if (this.$refs.loadingCover) this.$refs.loadingCover.show(); + }, + onLoad() { + if (!this.location) this.$util.getLocation(); + // #ifdef MP + this.menuButtonBounding = uni.getMenuButtonBoundingClientRect(); + // #endif + }, + watch: { + location: function(nVal) { + if (nVal) { + this.getOrderPaymentData(); + } + } + }, + filters: { + // 金额格式化输出 + moneyFormat(money) { + return parseFloat(money).toFixed(2); + } + } } \ No newline at end of file diff --git a/pages_tool/components/ns-chat/ns-chat-receiveGoods.vue b/pages_tool/components/ns-chat/ns-chat-receiveGoods.vue index 96edabb..ee2d4f6 100644 --- a/pages_tool/components/ns-chat/ns-chat-receiveGoods.vue +++ b/pages_tool/components/ns-chat/ns-chat-receiveGoods.vue @@ -1,142 +1,142 @@ - - - - - + + + + + diff --git a/pages_tool/goods/brand.vue b/pages_tool/goods/brand.vue index 35322fb..4ba5448 100644 --- a/pages_tool/goods/brand.vue +++ b/pages_tool/goods/brand.vue @@ -45,7 +45,7 @@ onShow() {}, methods: { change(e) { - this.$util.redirectTo('/pages/goods/list', { + this.$util.redirectTo('/pages_goods/list', { brand_id: this.brandList[e.detail.index].brand_id }); }, diff --git a/pages_tool/goods/coupon.vue b/pages_tool/goods/coupon.vue index e8d99a8..5405b52 100644 --- a/pages_tool/goods/coupon.vue +++ b/pages_tool/goods/coupon.vue @@ -240,11 +240,11 @@ }, toGoodsList(item) { if (item.goods_type != 1) { - this.$util.redirectTo('/pages/goods/list', { + this.$util.redirectTo('/pages_goods/list', { coupon: item.coupon_type_id }); } else { - this.$util.redirectTo('/pages/goods/list', {}); + this.$util.redirectTo('/pages_goods/list', {}); } } } diff --git a/pages_tool/goods/search.vue b/pages_tool/goods/search.vue index 72bcd9c..df4eddf 100644 --- a/pages_tool/goods/search.vue +++ b/pages_tool/goods/search.vue @@ -3,8 +3,8 @@ - - + + @@ -153,7 +153,7 @@ } uni.setStorageSync('search', array); - this.$util.redirectTo('/pages/goods/list', { + this.$util.redirectTo('/pages_goods/list', { keyword: this.inputValue.trim() }); } else { @@ -162,7 +162,7 @@ title: '搜索内容不能为空哦' }); } else { - this.$util.redirectTo('/pages/goods/list', { + this.$util.redirectTo('/pages_goods/list', { //keyword: this.searchWords }); } diff --git a/pages_tool/member/balance_detail.vue b/pages_tool/member/balance_detail.vue index 674e0f7..1485c7d 100644 --- a/pages_tool/member/balance_detail.vue +++ b/pages_tool/member/balance_detail.vue @@ -189,11 +189,11 @@ }, toFromDetail(item) { if (item.from_type == 'order' && !isNaN(parseInt(item.type_tag))) { - this.$util.redirectTo('/pages/order/detail', { + this.$util.redirectTo('/pages_order/detail', { order_id: item.type_tag }); } else if (item.from_type == 'refund' && parseInt(item.type_tag) != 0) { - this.$util.redirectTo('/pages/order/detail', { + this.$util.redirectTo('/pages_order/detail', { order_id: item.type_tag }); } diff --git a/pages_tool/member/coupon.vue b/pages_tool/member/coupon.vue index b646bc9..31ca8a8 100644 --- a/pages_tool/member/coupon.vue +++ b/pages_tool/member/coupon.vue @@ -169,7 +169,7 @@ }, toGoodsList(item) { if (item.state == 1) { - this.$util.redirectTo('/pages/goods/list', { + this.$util.redirectTo('/pages_goods/list', { coupon: item.coupon_type_id }); } diff --git a/pages_tool/member/footprint.vue b/pages_tool/member/footprint.vue index 3938105..2287446 100644 --- a/pages_tool/member/footprint.vue +++ b/pages_tool/member/footprint.vue @@ -229,7 +229,7 @@ export default { dateList = []; }, toDetail(e) { - this.$util.redirectTo('/pages/goods/detail', { + this.$util.redirectTo('/pages_goods/detail', { goods_id: e.goods_id }); } diff --git a/pages_tool/member/point_detail.vue b/pages_tool/member/point_detail.vue index fd52a39..70ca026 100644 --- a/pages_tool/member/point_detail.vue +++ b/pages_tool/member/point_detail.vue @@ -150,22 +150,22 @@ export default { if (data.type == 1 && data.relate_order_id) { switch (data.delivery_type) { case 'store': - this.$util.redirectTo('/pages/order/detail_pickup', { + this.$util.redirectTo('/pages_order/detail_pickup', { order_id: data.relate_order_id }); break; case 'local': - this.$util.redirectTo('/pages/order/detail_local_delivery', { + this.$util.redirectTo('/pages_order/detail_local_delivery', { order_id: data.relate_order_id }); break; default: - this.$util.redirectTo('/pages/order/detail', { + this.$util.redirectTo('/pages_order/detail', { order_id: data.relate_order_id }); } } else { - this.$util.redirectTo('/pages/order/detail_point', { + this.$util.redirectTo('/pages_order/detail_point', { order_id: data.order_id }); } @@ -173,19 +173,19 @@ export default { } }); } else if (item.from_type == 'pointcash') { - this.$util.redirectTo('/pages/order/detail', { + this.$util.redirectTo('/pages_order/detail', { order_id: item.type_tag }); } else if (item.from_type == 'memberconsume') { - // this.$util.redirectTo('/pages/order/detail', { + // this.$util.redirectTo('/pages_order/detail', { // order_id: item.type_tag // }); } else if (item.from_type == 'pointexchangerefund' && parseInt(item.type_tag) != 0) { - this.$util.redirectTo('/pages/order/detail_point', { + this.$util.redirectTo('/pages_order/detail_point', { order_id: item.type_tag }); } else if (item.from_type == 'refund' && parseInt(item.type_tag) != 0) { - this.$util.redirectTo('/pages/order/detail', { + this.$util.redirectTo('/pages_order/detail', { order_id: item.type_tag }); } diff --git a/pages_tool/member/public/js/collection.js b/pages_tool/member/public/js/collection.js index 9f9189b..2a44011 100644 --- a/pages_tool/member/public/js/collection.js +++ b/pages_tool/member/public/js/collection.js @@ -8,7 +8,7 @@ export default { methods: { //跳转至详情页 toDetail(e) { - this.$util.redirectTo("/pages/goods/detail", { + this.$util.redirectTo("/pages_goods/detail", { goods_id: e.goods_id }); }, diff --git a/pages_tool/order/detail_virtual.vue b/pages_tool/order/detail_virtual.vue index a07c408..4ee31cb 100644 --- a/pages_tool/order/detail_virtual.vue +++ b/pages_tool/order/detail_virtual.vue @@ -13,7 +13,7 @@ export default { }, onLoad(option) { if (option.order_id) { - this.$util.redirectTo('/pages/order/detail', {order_id: option.order_id}, 'redirectTo'); + this.$util.redirectTo('/pages_order/detail', {order_id: option.order_id}, 'redirectTo'); } } }; diff --git a/pages_tool/order/logistics.vue b/pages_tool/order/logistics.vue index 0856b0a..8aea65c 100644 --- a/pages_tool/order/logistics.vue +++ b/pages_tool/order/logistics.vue @@ -128,7 +128,7 @@ export default { title: '未获取到订单信息!' }); setTimeout(() => { - this.$util.redirectTo('/pages/order/list'); + this.$util.redirectTo('/pages_order/list'); }, 1500); } }, @@ -138,7 +138,7 @@ export default { }); }, toGoodsDetail(e) { - this.$util.redirectTo('/pages/goods/detail', { sku_id: e }); + this.$util.redirectTo('/pages_goods/detail', { sku_id: e }); }, imageError(packageIndex, goodsIndex) { this.packageList[packageIndex].goods_list[goodsIndex].sku_image = this.$util.getDefaultImage().goods; diff --git a/pages_tool/order/public/js/evaluate.js b/pages_tool/order/public/js/evaluate.js index bd86771..63ebd01 100644 --- a/pages_tool/order/public/js/evaluate.js +++ b/pages_tool/order/public/js/evaluate.js @@ -23,7 +23,7 @@ export default { }, onLoad(options) { //接收订单号,订单是否是追评等信息 - options.order_id ? (this.orderId = options.order_id) : this.$util.redirectTo('/pages/order/list'); + options.order_id ? (this.orderId = options.order_id) : this.$util.redirectTo('/pages_order/list'); this.isIphoneX = this.$util.uniappIsIPhoneX(); if (!this.storeToken) { @@ -90,7 +90,7 @@ export default { title: "未获取到订单数据" }) setTimeout(() => { - this.$util.redirectTo('/pages/order/list', {}, "redirectTo"); + this.$util.redirectTo('/pages_order/list', {}, "redirectTo"); }, 1000) } if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); @@ -200,7 +200,7 @@ export default { title: "评价成功" }); setTimeout(() => { - this.$util.redirectTo('/pages/order/list', {}, "redirectTo"); + this.$util.redirectTo('/pages_order/list', {}, "redirectTo"); }, 1000); } else { this.$util.showToast({ diff --git a/pages_tool/order/refund.vue b/pages_tool/order/refund.vue index 7cfd496..5899a94 100644 --- a/pages_tool/order/refund.vue +++ b/pages_tool/order/refund.vue @@ -179,7 +179,7 @@ export default { } else { this.$util.showToast({ title: '未获取到该订单项退款信息' }); setTimeout(() => { - this.$util.redirectTo('/pages/order/list'); + this.$util.redirectTo('/pages_order/list'); }, 1000); } }, diff --git a/pages_tool/order/refund_batch.vue b/pages_tool/order/refund_batch.vue index a9e3084..7a14556 100644 --- a/pages_tool/order/refund_batch.vue +++ b/pages_tool/order/refund_batch.vue @@ -171,7 +171,7 @@ export default { } else { this.$util.showToast({ title: '未获取到该订单项退款信息' }); setTimeout(() => { - this.$util.redirectTo('/pages/order/list'); + this.$util.redirectTo('/pages_order/list'); }, 1000); } }, diff --git a/pages_tool/order/refund_detail.vue b/pages_tool/order/refund_detail.vue index 898bf3e..0b47504 100644 --- a/pages_tool/order/refund_detail.vue +++ b/pages_tool/order/refund_detail.vue @@ -197,7 +197,7 @@ export default { } else { this.$util.showToast({ title: '未获取到该订单项退款信息' }); setTimeout(() => { - this.$util.redirectTo('/pages/order/list'); + this.$util.redirectTo('/pages_order/list'); }, 1000); } }, @@ -213,7 +213,7 @@ export default { if (res.code >= 0) { this.$util.showToast({ title: '撤销成功' }); setTimeout(() => { - this.$util.redirectTo('/pages/order/list'); + this.$util.redirectTo('/pages_order/list'); }, 1000); } }); @@ -264,7 +264,7 @@ export default { this.$forceUpdate(); }, refundDetail(e) { - this.$util.redirectTo('/pages/goods/detail', { + this.$util.redirectTo('/pages_goods/detail', { goods_id: e.goods_id }); } diff --git a/pages_tool/order/refund_goods_select.vue b/pages_tool/order/refund_goods_select.vue index f34e376..0bed4f5 100644 --- a/pages_tool/order/refund_goods_select.vue +++ b/pages_tool/order/refund_goods_select.vue @@ -55,7 +55,7 @@ icon:'none' }) setTimeout(()=>{ - this.$util.redirectTo('/pages/order/list'); + this.$util.redirectTo('/pages_order/list'); },1000) } }, diff --git a/pages_tool/order/refund_type_select.vue b/pages_tool/order/refund_type_select.vue index 1356ef1..52c1418 100644 --- a/pages_tool/order/refund_type_select.vue +++ b/pages_tool/order/refund_type_select.vue @@ -83,7 +83,7 @@ title: '未获取到该订单项退款信息' }); setTimeout(() => { - this.$util.redirectTo('/pages/order/list'); + this.$util.redirectTo('/pages_order/list'); }, 1000); } }, diff --git a/pages_tool/pay/result.vue b/pages_tool/pay/result.vue index 818ece9..cb93604 100644 --- a/pages_tool/pay/result.vue +++ b/pages_tool/pay/result.vue @@ -148,11 +148,11 @@ }, toOrderDetail(id) { if (this.payInfo.order_type == 2) { - this.$util.redirectTo('/pages/order/detail_pickup', { + this.$util.redirectTo('/pages_order/detail_pickup', { order_id: id }, 'redirectTo'); } else if (this.payInfo.order_type == 3) { - this.$util.redirectTo('/pages/order/detail_local_delivery', { + this.$util.redirectTo('/pages_order/detail_local_delivery', { order_id: id }, 'redirectTo'); } else if (this.payInfo.order_type == 4) { @@ -160,7 +160,7 @@ order_id: id }, 'redirectTo'); } else { - this.$util.redirectTo('/pages/order/detail', { + this.$util.redirectTo('/pages_order/detail', { order_id: id }, 'redirectTo'); } diff --git a/store/index.js b/store/index.js index a98653c..b0382c6 100644 --- a/store/index.js +++ b/store/index.js @@ -80,7 +80,7 @@ const store = new Vuex.Store({ }, copyright: null, initStatus:false, - offlineWhiteList:['pages/order/payment','pages/order/list','pages/order/detail'],//线下支付白名单 + offlineWhiteList:['pages_order/payment','pages_order/list','pages_order/detail'],//线下支付白名单 canReceiveRegistergiftInfo: { status: false, path: ''