From 5a8347e8a64bd6b5634f7177ca25c43a6baac7f3 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期三, 04 十二月 2024 14:26:38 +0800 Subject: [PATCH] 商品扫码激活 --- app.json | 3 + pages/home/home.js | 2 pages/scanResult/index.js | 38 +++++++++++------- pages/scanResult/index.wxss | 8 ++++ pages/scanResult/index.wxml | 55 +++++++++++++++++++++------ 5 files changed, 76 insertions(+), 30 deletions(-) diff --git a/app.json b/app.json index 1030dd3..0ca18c9 100644 --- a/app.json +++ b/app.json @@ -28,7 +28,8 @@ "pages/specialDiscussion/webView/index", "pages/index/bookDetail", "pages/index/resourceCover", - "pages/test/testCover" + "pages/test/testCover", + "pages/scanResult/index" ], "subPackages": [ { diff --git a/pages/home/home.js b/pages/home/home.js index 4cee2d9..a70fd1b 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -655,7 +655,7 @@ }) } else { wx.redirectTo({ - url: '/pages/index/scanResult/index?result=' + res.result, + url: '/pages/scanResult/index?result=' + res.result, }) } } diff --git a/pages/scanResult/index.js b/pages/scanResult/index.js index 1164b30..e9acf13 100644 --- a/pages/scanResult/index.js +++ b/pages/scanResult/index.js @@ -1,6 +1,5 @@ // pages/index/scanResult/index.js const app = getApp() - Page({ /** @@ -15,7 +14,9 @@ isOther: false, activeCodeAndStoreChannelLinks: [], activeInfo: null, - description: "" + description: "", + itemType: '', + goodsData: '' }, /** @@ -29,14 +30,17 @@ result, textValue: result.type == "PromoteCode" ? '棰嗗彇' : '婵�娲�' }) - this.getRules(); + // this.getRules(); this.getProductByCode(); } else { + debugger this.setData({ isOther: true }) } } catch (error) { + console.log(error); + debugger this.setData({ isOther: true }) @@ -139,9 +143,7 @@ showCancel: false, success(res) { if (res.confirm) { - setTimeout(() => { - wx.navigateBack() - }, 2500); + wx.navigateBack() } } }) @@ -161,7 +163,13 @@ .then(res => { try { const list = JSON.parse(res.config); + console.log('code', res, list); if (this.data.result) { + + const type = res.saleMethodList[0].type + this.setData({ + goodsData: res, + }) this.getProductListById(list); } if (res?.activeCodeAndStoreChannelLinks) { @@ -206,19 +214,15 @@ app.MG.store .getProductList({ queryType: "*", - subAccess: [{ - StoreRefCode: app.config.learnPlatformGoodsStore, // 榛樿鍟嗗搧搴� - Path: "", - Type: "*", - }, ], + // subAccess: [{ + // StoreRefCode: app.config.learnPlatformGoodsStore, // 榛樿鍟嗗搧搴� + // Path: "", + // Type: "*", + // }, ], sort: { CreateDate: "Desc", }, fields: { - tourism_author: [], - tourism_paperPrice: [], - tourism_publicationDate: [], - tourism_ISBN: [], "Id=": ids.map(item => item.id + ""), }, paging: { @@ -231,9 +235,13 @@ }) .then(res => { res.datas.map(item => { + item.name = item.name + '-' + this.data.goodsData.saleMethodList[0].name item.price ? item.price = (item.price).toFixed(2) : ""; item.oldPrice ? item.oldPrice = (item.oldPrice).toFixed(2) : ""; + item.icon ? item.icon = item.icon : item.icon = "/static/images/default-book-img.png", + item.itemType = this.data.goodsData.saleMethodList[0].type == 'createProductFolderSaleMethod' ? '鐩綍' : this.data.goodsData.saleMethodList[0].type == 'createProductItemSaleMethod' ? '璧勬簮' : '鐢靛瓙涔�' }) + console.log(1, res.datas[0]); that.setData({ productInfo: res.datas }) diff --git a/pages/scanResult/index.wxml b/pages/scanResult/index.wxml index 5073613..ffc3785 100644 --- a/pages/scanResult/index.wxml +++ b/pages/scanResult/index.wxml @@ -1,30 +1,54 @@ <!--pages/index/scanResult/index.wxml--> <view class="content" wx:if="{{!isOther}}"> <view class="productWall" wx:if="{{productInfo.length > 0}}"> - <view class="product" wx:for="{{productInfo}}" wx:for-item="item" wx:for-index="index" wx:key="index"> + <view + class="product" + wx:for="{{productInfo}}" + wx:for-item="item" + wx:for-index="index" + wx:key="index" + > <view class="productImg"> <image class="icon" src="{{item.icon}}" mode="aspectFit" /> </view> <view class="productInfo"> <text wx:if="{{item.name}}" class="publicCss">{{ item.name }}</text> - <text wx:if="{{item.tourism_ISBN}}" class="publicCss">ISBN锛歿{ item.tourism_ISBN }}</text> - <text wx:if="{{item.tourism_author}}" class="publicCss">浣滆�咃細{{ item.tourism_author }}</text> - <text wx:if="{{item.price}}" class="publicCss">浠锋牸锛�<text style="color:red">锟{ item.price }}</text></text> + <text wx:if="{{item.price}}" class="publicCss" + >浠锋牸锛�<text style="color: red">锟{ item.price }}</text></text + > + <text class="type-box">{{item.itemType}}</text> </view> </view> </view> <view class="selectCard" wx:if="{{activeCodeAndStoreChannelLinks.length>0}}"> - <t-cell title="{{description?description:'閫夋嫨婵�娲诲晢鍝�'}}" bordered="{{false}}" bindtap="selectPage" description="{{activeInfo && activeInfo.productIds.length>0?'宸查�夋嫨'+ activeInfo.productIds.length +'浠跺晢鍝�':''}}" data-info="{{activeCodeAndStoreChannelLinks}}" arrow /> + <t-cell + title="{{description?description:'閫夋嫨婵�娲诲晢鍝�'}}" + bordered="{{false}}" + bindtap="selectPage" + description="{{activeInfo && activeInfo.productIds.length>0?'宸查�夋嫨'+ activeInfo.productIds.length +'浠跺晢鍝�':''}}" + data-info="{{activeCodeAndStoreChannelLinks}}" + arrow + /> </view> <view class="couponWall" wx:if="{{couponList.length > 0}}"> - <view class="coupon" wx:for="{{couponList}}" wx:for-item="item" wx:for-index="index" wx:key="index"> - <image class="couponIcon" src="/static/images/web/coupon.png" mode="aspectFit" /> + <view + class="coupon" + wx:for="{{couponList}}" + wx:for-item="item" + wx:for-index="index" + wx:key="index" + > + <image + class="couponIcon" + src="/static/images/web/coupon.png" + mode="aspectFit" + /> <view class="price">锟{ item.value }}鍏�</view> <view class="couponInfo"> <text>{{ item.name }}</text> - <text class="timer">{{ - item.isForAllProduct ? "鍏ㄥ満鍙敤" : "浠呭彲璐拱鎸囧畾鍟嗗搧" - }}</text> + <text class="timer" + >{{ item.isForAllProduct ? "鍏ㄥ満鍙敤" : "浠呭彲璐拱鎸囧畾鍟嗗搧" }}</text + > <view class="timer"> <text>{{ item.start }}</text> <text>~</text> @@ -33,8 +57,13 @@ </view> </view> </view> - <view class="button-example" wx:if="{{productInfo.length > 0 || couponList.length > 0}}"> - <t-button theme="danger" bindtap="useActiveCode" size="large" block>{{textValue}}</t-button> + <view + class="button-example" + wx:if="{{productInfo.length > 0 || couponList.length > 0}}" + > + <t-button bindtap="useActiveCode" size="large" block + >{{textValue}}</t-button + > </view> <view class="text"> <rich-text space="emsp" nodes="{{rules.tourism_content}}" /> @@ -42,4 +71,4 @@ </view> <view wx:else class="empyt"> <t-empty icon="error-circle" description="璇锋壂鎻忔纭殑浜岀淮鐮�" /> -</view> \ No newline at end of file +</view> diff --git a/pages/scanResult/index.wxss b/pages/scanResult/index.wxss index 95fd2c3..8561e64 100644 --- a/pages/scanResult/index.wxss +++ b/pages/scanResult/index.wxss @@ -133,4 +133,12 @@ .publicCss { font-size: 28rpx; padding: 10rpx 0; +} + +.type-box { + font-size: 28rpx; + color: #FF6C00; + background: rgba(255, 108, 0, 0.24); + padding: 4rpx 8rpx; + border-radius: 9rpx; } \ No newline at end of file -- Gitblit v1.9.1