闫增涛
2024-12-04 5a8347e8a64bd6b5634f7177ca25c43a6baac7f3
商品扫码激活
5个文件已修改
106 ■■■■ 已修改文件
app.json 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/home/home.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/scanResult/index.js 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/scanResult/index.wxml 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/scanResult/index.wxss 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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": [
    {
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,
            })
          }
        }
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
        })
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>
</view>
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;
}