Prechádzať zdrojové kódy

小程序:个人中心

panyong 2 rokov pred
rodič
commit
3b4d319373

+ 6 - 24
htmldev/wxMini/pages/businessGoodsManage/api/index.js

@@ -1,11 +1,11 @@
 const { request } = require('../../../api/request')
 /**
- * 订单列表
+ * 商品列表
  * @param obj
  * @returns {Promise}
  */
-export const getOrderList = (obj) => request({
-  url: '/api/user/order/list',
+export const getProductList = (obj) => request({
+  url: '/api/shop/product/list',
   method: 'POST',
   data: {
     'page': obj.pageNum,
@@ -15,30 +15,12 @@ export const getOrderList = (obj) => request({
   showLoading: true
 })
 /**
- * 订单删除
+ * 商品删除
  * @param id
  * @returns {Promise | Promise<unknown>}
  */
-export const postOrderDelete = (id) => request({
-  url: '/api/user/order/delete',
-  method: 'POST',
-  data: {
-    id
-  },
-  showLoading: true
-})
-
-export const postOrderDiffPay = (id) => request({
-  url: '/api/user/order/delete',
-  method: 'POST',
-  data: {
-    id
-  },
-  showLoading: true
-})
-
-export const postOrderCancel = (id) => request({
-  url: '/api/user/order/delete',
+export const postProductDelete = (id) => request({
+  url: '/api/shop/product/delete',
   method: 'POST',
   data: {
     id

+ 12 - 113
htmldev/wxMini/pages/businessGoodsManage/businessGoodsManage.js

@@ -1,4 +1,4 @@
-const { getOrderList, postOrderDelete, postOrderDiffPay, postOrderCancel } = require('./api/index')
+const { getProductList, postProductDelete } = require('./api/index')
 
 Page({
 
@@ -31,8 +31,6 @@ Page({
     booDeleteOrder: false,
     booLock: false,
     refresherThreshold: 60, // 自定义下拉刷新阈值
-    booCancelOrder: false,
-    booPayment: false,
     itemData: {} // 当前选中的订单
   },
   // 下拉刷新加锁
@@ -77,9 +75,10 @@ Page({
     this.onRefresh({ detail: { dy: this.data.refresherThreshold } })
   },
   jumpOrderDetail(e) {
-    const { orderId } = e.currentTarget.dataset
+    const { item } = e.currentTarget.dataset
+
     wx.navigateTo({
-      url: '/pages/orderDetail/orderDetail?orderId=' + orderId
+      url: '/pages/orderDetail/orderDetail?orderId=' + item.id
     })
   },
   setOriginScrollViewData() {
@@ -99,7 +98,7 @@ Page({
     this.setData({
       originScrollViewData: temp
     }, () => {
-      // this.fetOrderList()
+      this.fetOrderList()
     })
   },
   changeTabs(e) {
@@ -112,7 +111,7 @@ Page({
       current: index
     }, () => {
       if (temp.isFirst) {
-        // this.fetOrderList()
+        this.fetOrderList()
       }
     })
   },
@@ -125,7 +124,7 @@ Page({
       }, () => {
         const temp = this.data.originScrollViewData[current]
         if (temp.isFirst) {
-          // this.fetOrderList()
+          this.fetOrderList()
         }
       })
     }
@@ -152,7 +151,7 @@ Page({
       ['originScrollViewData[' + _tab + '].pageNum']: temp.pageNum + 1
     })
     try {
-      const { status, data, msg } = await getOrderList({
+      const { status, data, msg } = await getProductList({
         pageNum: that.data.originScrollViewData[_tab].pageNum,
         pageSize: that.data.pageSize,
         type: that.data.tabs[_tab].value
@@ -160,15 +159,9 @@ Page({
       if (status) {
         const { list } = data
         if (Array.isArray(list)) {
-          const arr = list.map(item => {
-            return {
-              ...item,
-              created_at: item.created_at.replace(/(.*)(:\d{2})/, '$1')
-            }
-          })
           const _list = temp.isRefresh
-            ? [].concat(arr)
-            : that.data.originScrollViewData[_tab].list.concat(arr)
+            ? [].concat(list)
+            : that.data.originScrollViewData[_tab].list.concat(list)
 
           that.setData({
             ['originScrollViewData[' + _tab + '].list']: _list,
@@ -206,7 +199,7 @@ Page({
         ['originScrollViewData[' + _tab + '].isRefresh']: true,
         ['originScrollViewData[' + _tab + '].isFetchLock']: false
       }, () => {
-        // this.fetOrderList()
+        this.fetOrderList()
       })
     }, 1000)
   },
@@ -231,7 +224,7 @@ Page({
       booLock: true
     })
     try {
-      const { status, msg } = await postOrderDelete(id)
+      const { status, msg } = await postProductDelete(id)
       let _msg = ''
       if (status) {
         _msg = '订单删除成功'
@@ -257,101 +250,7 @@ Page({
         icon: 'none'
       })
     } catch (err) {}
-    this.setData({
-      booLock: false
-    })
-  },
-  showPayment(e) {
-    const { item } = e.currentTarget.dataset
-
-    this.setData({
-      itemData: item,
-      booPayment: true
-    })
-  },
-  hidePayment() {
-    this.setData({
-      booPayment: false,
-      itemData: {}
-    })
-  },
-  async handleOrderDiffPay() {
-    const { order_number, id } = this.data.itemData
-
-    this.setData({
-      booLock: true
-    })
-
-    try {
-      const { status, data, msg } = await postOrderDiffPay(order_number)
-      if (status) {
-        const { time_stamp, nonce_str, sign_type, pay_sign } = data.pay_data
-        wx.requestPayment({
-          timeStamp: time_stamp,
-          nonceStr: nonce_str,
-          package: data.pay_data.package,
-          signType: sign_type,
-          paySign: pay_sign,
-          success(res) {
-            if (res.errMsg === 'requestPayment:ok') {
-              wx.redirectTo({
-                url: '/pages/orderDetail/orderDetail?orderId=' + id
-              })
-            } else {
-              wx.showToast({
-                title: '支付出错,请重试~',
-                icon: 'none'
-              })
-            }
-          },
-          fail(err) {
-            console.log(err)
-          }
-        })
-      } else {
-        wx.showToast({
-          title: msg,
-          icon: 'none'
-        })
-      }
-    } catch (err) {}
-    this.setData({
-      booLock: false
-    })
-  },
-  showCancelOrder(e) {
-    const { item } = e.currentTarget.dataset
 
-    this.setData({
-      itemData: item,
-      booCancelOrder: true
-    })
-  },
-  hideCancelOrder() {
-    this.setData({
-      booCancelOrder: false,
-      itemData: {}
-    })
-  },
-  async confirmCancelOrder() {
-    const { id } = this.data.itemData
-    this.setData({
-      booLock: true
-    })
-    try {
-      const { status, msg } = await postOrderCancel(id)
-      if (status) {
-        this.hideCancelOrder()
-        wx.redirectTo({
-          url: '/pages/orderCancel/orderCancel?orderId=' + id
-        })
-      } else {
-        wx.showToast({
-          title: msg,
-          icon: 'none'
-        })
-      }
-    } catch (err) {}
     this.setData({
       booLock: false
     })

+ 0 - 1
htmldev/wxMini/pages/businessGoodsManage/businessGoodsManage.scss

@@ -123,7 +123,6 @@
     display: block;
     width: 100%;
     height: 100%;
-    background: pink;
   }
 }
 

+ 23 - 91
htmldev/wxMini/pages/businessGoodsManage/businessGoodsManage.wxml

@@ -42,11 +42,10 @@
         </view>
 
         <view class="list"
-              wx:for="{{[1]}}"
+              wx:for="{{item.list}}"
               wx:for-item="order"
-              wx:key="id"
-              data-order-id="{{order.id}}"
-              bind:tap="jumpOrderDetail">
+              wx:key="id">
+          <!-- todo 货号 审核状态 -->
           <view class="top">
             <view>产品货号:12345678900</view>
             <!-- 已上架 审核未通过 -->
@@ -54,25 +53,34 @@
           </view>
           <view class="middle">
             <view class="photo-wrap">
-              <image src=""></image>
+              <image src="{{order.product_img_url}}"></image>
             </view>
             <view class="name-wrap">
-              <view class="name">大西瓜</view>
+              <view class="name">{{order.product_title}}</view>
               <view class="box">
-                <view class="stock">库存:300</view>
-                <view class="price">价格: ¥39.22</view>
+                <view class="stock">库存:{{order.product_count}}</view>
+                <view class="price">价格: ¥{{tools.fen2Yuan(order.product_price)}}</view>
               </view>
             </view>
           </view>
           <view class="bottom">
-            <button type="default">删除产品</button>
-            <button type="default">修改价格</button>
-            <button type="default" style="color: rgba(107, 133, 89, 1);">查看详情</button>
+            <button
+              type="default"
+              data-item="{{order}}"
+              catch:tap="showDeleteOrder">删除产品
+            </button>
+            <button
+              type="default"
+              style="color: rgba(107, 133, 89, 1);"
+              data-item="{{order}}"
+              bind:tap="jumpOrderDetail">编辑产品
+            </button>
           </view>
         </view>
 
-        <view class="list-bitmap" wx:if="{{item.finished && item.list.length < 1}}">
-          <image src="{{tools.imgFilter('/common/Order_page_default@2x.png')}}"></image>
+        <view
+          class="list-bitmap"
+          wx:if="{{item.finished && item.list.length < 1}}">
           <text>暂无订单</text>
         </view>
 
@@ -92,13 +100,13 @@
   </swiper>
 </view>
 
-  <!-- 弹窗:删除订单二次确认 -->
+  <!-- 弹窗:删除商品二次确认 -->
 <van-popup
   custom-class="customer-van-model"
   show="{{ booDeleteOrder }}"
   bind:close="hideDeleteOrder">
   <view class="customer-van-model_body">
-    <view class="content">订单删除后将无法恢复,您也无法再对它进行投诉。</view>
+    <view class="content">产品删除后将无法恢复,您确定删除吗?</view>
   </view>
   <view class="customer-van-model_footer">
     <button class="customer-van-model_cancel"
@@ -114,80 +122,4 @@
     </button>
   </view>
 </van-popup>
-
-  <!-- 弹窗:取消订单二次确认 -->
-<van-popup
-  custom-class="customer-van-model"
-  show="{{ booCancelOrder }}"
-  bind:close="hideCancelOrder">
-  <view class="customer-van-model_body">
-    <view class="content cancel-order" wx:if="{{itemData.order_status === 5}}">
-      <text wx:for="{{'司机车辆已安排,订单取消将'}}" wx:for-index="index" wx:key="index">{{item}}</text>
-      <text wx:for="{{'扣除定金'}}" wx:for-index="idx" wx:key="idx" style="color:#FD6600;">{{item}}</text>
-    </view>
-    <view class="content" wx:else>确认取消订单吗?</view>
-  </view>
-  <view class="customer-van-model_footer">
-    <button class="customer-van-model_cancel"
-            hover-class="none"
-            type="default"
-            disabled="{{booLock}}"
-            bind:tap="confirmCancelOrder">仍要取消
-    </button>
-    <button class="customer-van-model_confirm"
-            hover-class="none"
-            type="primary"
-            bind:tap="hideCancelOrder">继续用车
-    </button>
-  </view>
-</van-popup>
-  <!--弹窗:补价-->
-<van-popup
-  custom-class="customer-van-popup customer-van-popup-diff-price"
-  show="{{ booPayment }}"
-  close-on-click-overlay="{{false}}"
-  round
-  position="bottom"
-  bind:close="hidePayment">
-  <view style="right:0;top:0;"
-        class="close-icon"
-        bind:tap="hidePayment">
-    <image class="image" src="{{tools.imgFilter('/common/Popup_bus_icon_close@2x.png')}}"></image>
-  </view>
-  <view class="title">补价</view>
-  <view class="customer-van-popup-diff-price-body">
-    <view class="alert">
-      <view>根据商定的实际需支付金额,调整订单总金额及增付相应定金。平台定价系统升级前,暂时需人工调整合理价格,敬请谅解~
-      </view>
-    </view>
-    <view class="amount">
-      <view class="label">
-        <view>订单总金额</view>
-        <view>(调整后)</view>
-      </view>
-      <view class="value">{{tools.fen2Yuan(itemData.order_price)}}元</view>
-    </view>
-    <view class="diff-price">
-      <text class="label">¥</text>
-      <text class="value">{{tools.fen2Yuan(itemData.order_diff_price)}}</text>
-    </view>
-    <view class="diff-price-text">需增付定金</view>
-    <view class="wechat">
-      <view class="name">
-        <image class="logo"
-               src="{{tools.imgFilter('/createOrder/Popup_defray_logo_wechat@2x.png')}}"></image>
-        <text>微信支付</text>
-      </view>
-      <image class="checked"
-             src="{{tools.imgFilter('/createOrder/Reason_btn_check@2x.png')}}"></image>
-    </view>
-  </view>
-  <button class="customer-picker_footer"
-          style="background-color: #FD6600;"
-          hover-class="none"
-          type="primary"
-          disabled="{{booLock}}"
-          bind:tap="handleOrderDiffPay">立即支付
-  </button>
-</van-popup>
 <wxs src="../../components/wxs/index.wxs" module="tools"></wxs>