绿满眶商城微信小程序-uniapp
peng
1 天以前 d50a3ed44e2edab2a7a661c43491c3aa42c57794
pages/video/video-goods-detail.vue
@@ -29,8 +29,9 @@
<script>
   import {getGoodsDetail} from "@/api/video.js"
   import { buyBack } from "@/api/trade.js";
   import '@/components/uview-components/uview-ui';
   import { getSessionId, userAction } from "@/api/userAction.js";
   export default {
      computed: {
         totalMoney() {
@@ -45,14 +46,53 @@
      data() {
         return {
            videoId: '',
            goodsList: []
            goodsList: [],
            pageSessionNo:"",
            actionParam:{
                  sessionId:'',
                  actionType:"PAGE",
                  joinType:"SELF",
                  pageCode:"RECOMMEND_VIDEO_GOODS",
                  pageParams:"{}",
                  pageStatus:"JOIN",
                  pageType:"DETAIL"
               }
         }
      },
    onUnload() {
      let   param = this.actionParam;
      if (this.sendOnShow)return
      param.pageStatus = "LEAVE"
      userAction(param)
    },
    onHide() {
      this.startHidenTime = Date.now()
      let   param = this.actionParam;
      this.sendOnShow = true;
      param.pageStatus = "LEAVE"
      userAction(param)
    },
      onShow() {
         getSessionId().then(res=>{
            this.pageSessionNo = res.data.data
            if(this.pageSessionNo){
            let   param = this.actionParam;
               param.sessionId = this.pageSessionNo
               userAction(param)
            }
         })
      },
      onLoad(option) {
         this.videoId = option.videoId;
         this.actionParam.pageParams = JSON.stringify(option)
         this.getGoodsList();
      },
      methods: {
         selectGoods(goods,id){
            uni.navigateTo({
               url: `/pages/product/goods?id=${goods.id}&goodsId=${goods.goodsId}`
            })
         },
         // 获取商品列表
         async getGoodsList() {
            getGoodsDetail(this.videoId).then(res => {
@@ -61,7 +101,17 @@
         },
         // 生成订单-支付
         toPay() {
            const buyList = this.goodsList.map(goods => {
               return {
                  skuId: goods.id,
                  num: goods.goodsNum
               }
            })
            buyBack(buyList).then(res => {
               uni.navigateTo({
                  url: "/pages/order/fillorder?way=CART"
               })
            })
         }
      }
   }