浏览代码

2023-4-27

cmy 1 年之前
父节点
当前提交
ec95897adc
共有 2 个文件被更改,包括 12 次插入10 次删除
  1. 2 2
      pages.json
  2. 10 8
      pages/goods_details/index.vue

+ 2 - 2
pages.json

@@ -1911,8 +1911,8 @@
     "current": 0, //当前激活的模式(list 的索引项)
     "list": [{
       "name": "测试", //模式名称
-      "path": "/pages/index/index", //启动页面,必选
-      "query": "id=1580" //启动参数,在页面的onLoad函数里面得到
+      "path": "/pages/goods_details/index", //启动页面,必选
+      "query": "id=1709" //启动参数,在页面的onLoad函数里面得到
     }]
   }
 }

+ 10 - 8
pages/goods_details/index.vue

@@ -757,12 +757,11 @@
 		},
 		async onLoad(options) {
 			if(!uni.getStorageSync('diyProduct')){
-				const diyDetail = await this.getdiyProduct()
+				this.diyProduct = await this.getdiyProduct()
+			}else{
+				this.diyProduct = JSON.parse(uni.getStorageSync('diyProduct'))
 			}
-			this.diyProduct = JSON.parse(uni.getStorageSync('diyProduct'))
-			console.log(this.diyProduct, 'this.diyProduct')
 			this.diyProduct.price_type = this.diyProduct.price_type + ''
-			console.log(this.diyProduct.price_type, 'this.diyProduct.price_type')
 			let that = this;
 			var pages = getCurrentPages();
 			that.returnShow = pages.length === 1 ? false : true;
@@ -934,11 +933,14 @@
 		methods: {
 			// div商品详情 用于处理bug
 			getdiyProduct() {
-				diyProduct().then(res => {
-					// console.log(JSON.stringify(res.data.product_detail))
-					uni.setStorageSync('diyProduct', JSON.stringify(res.data.product_detail));
-					Promise.resolve(res.data.product_detail)
+				return new Promise((resolve,reject)=>{
+					diyProduct().then(res => {
+						// console.log(JSON.stringify(res.data.product_detail))
+						uni.setStorageSync('diyProduct', JSON.stringify(res.data.product_detail));
+						resolve(res.data.product_detail);
+					})
 				})
+				
 			},
 			// 获取配送方式
 			deliveryFun(e) {