Selaa lähdekoodia

Merge branch 'skk/feat/welfare-mall' into jeffrey/feat/coupon-center

# Conflicts:
#	project.private.config.json
xing.li 3 vuotta sitten
vanhempi
commit
2255c11489

+ 35 - 0
api/welfareMall.js

@@ -0,0 +1,35 @@
+import request from '../utils/request.js'
+
+class WelfareMall extends request {
+
+  /**
+   * 获取订单
+   */
+  static getOrder(params) {
+    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/get`, params);
+  }
+
+  /**
+   * 取消订单
+   */
+  static cancelOrder(params) {
+    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/cancel`, params);
+  }
+
+  /**
+   * 订单列表
+   */
+  static getOrderList(params) {
+    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/list`, params);
+  }
+
+    /**
+   * 订单退款
+   */
+  static orderRefund(params) {
+    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/refund`, params, true)
+  }
+
+}
+
+export default WelfareMall

BIN
images/welfareMall/img-choice.png


BIN
images/welfareMall/toDelete.png


+ 90 - 1
pages/welfareMall/feedback/feedback.js

@@ -6,7 +6,8 @@ Page({
    */
   data: {
     t_length: 0,
-
+    avatarUrl: [],
+    chooseViewShowBanner: true
   },
 
   bindText: function (e) {
@@ -17,6 +18,94 @@ Page({
     }) 
   },
 
+   /** 图片选择 */
+   bindViewTap: function(){
+    var that = this;
+    if(this.data.avatarUrl.length < 4){
+      wx.chooseImage({
+        // 设置最多可以选择的图片张数,默认9,如果我们设置了多张,那么接收时//就不在是单个变量了,
+         count: 4, 
+         sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
+         sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
+         success: function(res){
+          // 获取成功,将获取到的地址赋值给临时变量
+          console.log(res.tempFilePaths);
+          if (res.tempFilePaths.count == 0) {
+            return;
+          }
+          //上传图片
+          var imgArrNow = that.data.avatarUrl;
+          imgArrNow = imgArrNow.concat(res.tempFilePaths);
+          if(that.data.avatarUrl.length +res.tempFilePaths.length > 4){
+            wx.showToast({
+              title: '最多添加4张图片',
+              icon: 'none',
+              duration: 1500
+            })
+            return
+          }
+          that.setData({
+          //将临时变量赋值给已经在data中定义好的变量
+           avatarUrl:imgArrNow
+          })
+          that.chooseViewShowBanner();
+         },
+         fail: function(res) {
+          // fail
+         },
+         complete: function(res) {
+          // complete
+         }
+        })
+    } else {
+      wx.showToast({
+        title: '最多添加4张图片',
+        icon: 'none',
+        duration: 1500
+      })
+    }
+   },
+
+   /** 删除图片Banner */
+  deleteImvBanner: function(e) {
+    var avatarUrl = this.data.avatarUrl;
+    var itemIndex = e.currentTarget.dataset.id;
+    avatarUrl.splice(itemIndex, 1);
+    this.setData({
+      avatarUrl: avatarUrl
+    })
+    //判断是否隐藏选择图片
+    this.chooseViewShowBanner();
+  },
+
+   /** 是否隐藏图片选择Banner*/
+   chooseViewShowBanner: function() {
+    if (this.data.avatarUrl.length >= 4) {
+      this.setData({
+        chooseViewShowBanner: false
+      })
+    } else {
+      this.setData({
+        chooseViewShowBanner: true
+      })
+    }
+  },
+
+   /** 图片预览 */
+  previewImage: function(e){
+    var that = this,
+    //获取当前图片的下标
+      index = e.currentTarget.dataset.index,
+      //数据源
+      avatarUrl = this.data.avatarUrl;
+    wx.previewImage({
+    //当前显示下标
+     current: avatarUrl[index],
+     //数据源
+     urls: avatarUrl
+    })
+   },
+
   /**
    * 生命周期函数--监听页面加载
    */

+ 28 - 6
pages/welfareMall/feedback/feedback.wxml

@@ -1,18 +1,40 @@
 <!--pages/welfareMall/feedback/feedback.wxml-->
 <view class="feedback flex-column">
   <view class="feedback-style flex-column">
-    <view class="feedback-title">建议</view>
+    <view class="feedback-titles flex-row">
+      <view class="feedback-title">建议</view>
+    </view>
     <view class="feedback-text flex-column">
-      <view class='suggest_box'>
-        <textarea class='suggest_text' bindinput="bindText" maxlength='200' placeholder='请输入您的建议' placeholder-class='sug_p'>
-          <text class="suggest_text-num flex-column">{{t_length}}/500</text>
+      <textarea class='suggest_text' bindinput="bindText" maxlength='500' placeholder='请输入您的建议' placeholder-class='sug_p'>
         </textarea>
-      </view>
+      <view class="suggest_text-count flex-row"><text class="suggest_text-num">{{t_length}}/500</text></view>
     </view>
     <view class="feedback-exp flex-row">
       <view class="feedback-explain">图片(选项)(最多添加4张)</view>
       <view></view>
     </view>
-    <view class="explain-img"></view>
+    <view class="explain-img flex-row">
+      <!--这个是已经选好的图片-->
+      <view class="explain-img-style flex-column" wx:for="{{avatarUrl}}" wx:key="key" data-index="{{index}}" bindtap="previewImage">
+        <view class="close-img-style flex-row">
+          <image class="close-img" src="" mode="scaleToFill" catchtap="deleteImvBanner" data-id="{{index}}" src="/images/welfareMall/toDelete.png"></image>
+        </view>
+        <image class="explain-img-preview " src="{{item}}"></image>
+      </view>
+      <!--这个是选择图片-->
+      <view bindtap="chooseBanner" wx:if="{{chooseViewShowBanner}}" catchtap="bindViewTap">
+        <view class="close-img-style">
+          <image class="close-img"></image>
+        </view>
+        <view class="explain-img-preview flex-column">
+          <image class="chooseImv" src="/images/welfareMall/img-choice.png"></image>
+        </view>
+      </view>
+    </view>
+    <view class="lower-submit flex-row">
+      <view class="order-refund flex-row">
+        <view class="lower-order-text">提交</view>
+      </view>
+    </view>
   </view>
 </view>

+ 82 - 2
pages/welfareMall/feedback/feedback.wxss

@@ -22,21 +22,43 @@
   justify-content: center;
 }
 
+.feedback-titles{
+  width: 659rpx;
+  height: 80rpx;
+  justify-content: flex-start;
+}
+
+.feedback-title{
+  font-size: 24rpx;
+  font-weight: 500;
+  color: #444444;
+}
+
 textarea{
   width: 659rpx;
   height: 320rpx;
   background: #FFFFFF;
   border: 1rpx solid #3E3E3E;
   border-radius: 10rpx;
+  z-index: 1;
+}
+
+.suggest_text-count{
+  width: 659rpx;
+  height: 40rpx;
+  justify-content: flex-end;
+  margin-right: 28rpx;
 }
 
 .suggest_text-num{
-  align-items: flex-end;
+  z-index: 2;
+  font-size: 26rpx;
+  margin-bottom: 86rpx;
 }
 
 .feedback-exp{
   width: 659rpx;
-  height: 120rpx;
+  height: 100rpx;
   justify-content: space-between;
 }
 
@@ -46,4 +68,62 @@ textarea{
   font-size: 24rpx;
   font-weight: 500;
   color: #444444;
+}
+
+.explain-img{
+  width: 659rpx;
+  height: 180rpx;
+  justify-content: space-between;
+}
+
+.explain-img-style{
+  width: 160rpx;
+  height: 180rpx;
+}
+
+.explain-img-preview{
+  width: 154rpx;
+  height: 154rpx;
+  border: 1rpx solid #3E3E3E;
+  border-radius: 10rpx;
+  z-index: 1;
+  justify-content: center;
+}
+
+.close-img-style{
+  width: 154rpx;
+  height: 22rpx;
+  justify-content: flex-end;
+  z-index: 2;
+}
+
+.close-img{
+  width: 22rpx;
+  height: 22rpx;
+  margin-top: 30rpx;
+  margin-right: -5rpx;
+}
+
+.chooseImv{
+  width: 65rpx;
+  height: 64rpx;
+}
+
+.lower-submit{
+  width: 659rpx;
+  height: 100rpx;
+  margin-top: 50rpx;
+}
+
+.order-refund{
+  width: 631rpx;
+  height: 90rpx;
+  background: #B01717;
+  border-radius: 50rpx;
+}
+
+.lower-order-text{
+  font-size: 36rpx;
+  font-weight: 500;
+  color: #FFFFFF;
 }

+ 69 - 3
pages/welfareMall/historical/historical.js

@@ -1,20 +1,80 @@
 // pages/welfareMall/historical/historical.js
+import WelfareMall from '../../../api/welfareMall'
+import { parseTime } from '../../../utils/util'
+import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../../utils/user'
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-
+    page: 1,
+    pageSize: 10,
+    lock: false,
+    noResult: false,
+    noMore: false,
+    mobileTop: 'TONY WU',
+    orderList: []
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    this.setData({
+      isLogin: getMobileCache() != ''
+    })
+    if(this.data.isLogin){
+        this.getOrderList();
+    }
 
   },
 
+  // 订单数据
+  getOrderList: function() {
+    WelfareMall.getOrderList({
+      page: this.data.page,
+      pageSize: this.data.pageSize,
+      mobile: getMobileCache(),
+    }).then(res => {
+        if (res.code == 200) {
+            this.userOrderListView(res.data)
+        }
+        this.data.lock = false
+    }).catch(_ => {
+        console.log(_)
+        this.data.lock = false
+    })
+},
+
+  userOrderListView: function(data) {
+    if (!Array.isArray(data) || data.length == 0) {
+        console.log("订单列表数据为空");
+        if (this.data.page == 1) {
+            this.setData({
+                mobileTop:getMobileCache(),
+                noResult: true
+            })
+        } else {
+            this.setData({
+                mobileTop:getMobileCache(),
+                noMore: true
+            })
+        }
+        return
+    }
+    // data.forEach(v => {
+    //     let payeTime = v.payedAt
+    //     v.payedAt = parseTime(payeTime, "{y}.{m}.{d} {h}:{i}:{s}")
+    // })
+
+    this.data.orderList = this.data.orderList.concat(...data)
+    this.setData({
+        mobileTop:getMobileCache(),
+        orderList: this.data.orderList
+    })
+  }, 
+
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
@@ -54,12 +114,18 @@ Page({
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {
+    if (this.data.lock || this.data.noMore) {
+      return
+    }
+    this.data.lock = true
+    this.data.page++
+    this.getOrderList();
 
   },
 
   getCompletion(e) {
-    const url = "../order/orderCompletion?id=" + e.currentTarget.dataset.id
-    wx.redirectTo({
+    const url = "../order/orderCompletion?ordersn=" + e.currentTarget.dataset.ordersn
+    wx.navigateTo({
         url
     })
   },

+ 12 - 10
pages/welfareMall/historical/historical.wxml

@@ -1,32 +1,34 @@
 <!--pages/welfareMall/historical/historical.wxml-->
 <!-- 历史订单 -->
 <view class="historical flex-column">
-  <view class="historical-style">
+  <view class="historical-style flex-column">
     <!-- 内容 -->
-    <view class="historical-content flex-column">
+    <view class="historical-content flex-column" wx:for="{{orderList}}" wx:key="index" data-ordersn="{{item.orderSn}}">
       <view class="content-hm flex-column">
         <view class="content-head flex-row">
-          <view class="content-head-date">2021.11.04 12:22:35</view>
-          <view class="content-head-state">已完成</view>
+          <view class="content-head-date">{{item.payedAt}}</view>
+          <view class="content-head-state">{{item.status.showText}}</view>
         </view>
         <view class="content-middle flex-row">
           <view class="middle-it flex-row">
-            <image class="middle-img" src="/images/welfareMall/middle_img.png" />
-            <view class="middle-text">圣诞优惠券包</view>
+            <image class="middle-img" src="{{item.goodsList[0].fullCoverImg}}" />
+            <view class="middle-text">{{item.goodsList[0].activityName}}</view>
           </view>
           <view class="middle-num flex-column">
-            <view class="middle-num-money">¥0.0</view>
-            <view class="money-num-count">x1</view>
+            <view class="middle-num-money">¥{{item.payPriceFormatter}}</view>
+            <view class="money-num-count">x{{item.goodsList.length}}</view>
           </view>
         </view>
       </view>
       <view class="content-line"></view>
-      <view class="content-lower flex-row" catchtap="getCompletion">
-        <view class="lower-total">共1件商品 合计¥9.9</view>
+      <view class="content-lower flex-row" data-ordersn="{{item.orderSn}}" catchtap="getCompletion">
+        <view class="lower-total">共{{item.goodsList.length}}件商品 合计¥{{item.payPriceFormatter}}</view>
         <view class="lower-order-style flex-row">
           <view class="lower-order-text">订单详情</view>
         </view>
       </view>
     </view>
+    <view class="no_result" wx:if="{{noResult}}">———— 抱歉,您暂无历史订单 ————</view>
+    <view class="no_result" wx:if="{{noMore}}">———— 更多订单 | 敬请期待 ————</view>
   </view>
 </view>

+ 8 - 1
pages/welfareMall/historical/historical.wxss

@@ -41,7 +41,7 @@
 }
 
 .content-head-date{
-  width: 211rpx;
+  width: 230rpx;
   height: 28rpx;
   font-size: 22rpx;
   font-weight: 500;
@@ -135,4 +135,11 @@
   font-size: 22rpx;
   font-weight: 500;
   color: #B01717;
+}
+
+.no_result {
+  font-size: 24rpx;
+  color: #B1B1B1;
+  line-height: 100rpx;
+  font-weight: 1000;
 }

+ 46 - 1
pages/welfareMall/order/orderCompletion.js

@@ -1,20 +1,65 @@
 // pages/welfareMall/order/orderCompletion.js
+import WelfareMall from '../../../api/welfareMall'
+import { parseTime } from '../../../utils/util'
+import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../../utils/user'
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-
+    page: 1,
+    pageSize: 10,
+    lock: false,
+    noResult: false,
+    noMore: false,
+    isLogin: false,
+    orderDetail: null,
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    var that = this;
+    that.orderSn = options.ordersn
+    this.setData({
+      isLogin: getMobileCache() != '',
+  })
+  if(this.data.isLogin){
+      this.getOrder(that.orderSn);
+  }
+  },
 
+  // 订单数据
+  getOrder: function(data) {
+    WelfareMall.getOrder({
+      mobile: getMobileCache(),
+      orderSn: data,
+    }).then(res => {
+        if (res.code == 200) {
+            this.userOrderistView(res.data)
+        }
+        this.data.lock = false
+    }).catch(_ => {
+        console.log(_)
+        this.data.lock = false
+    })
   },
 
+  userOrderistView: function(data) {
+    if (!data) {
+        console.log("订单详情数据为空");
+        return
+    }
+    //对象转换
+    this.data.orderDetail = data
+    this.setData({
+        mobileTop:getMobileCache(),
+        orderDetail: this.data.orderDetail
+    })
+  }, 
+
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

+ 29 - 8
pages/welfareMall/order/orderCompletion.wxml

@@ -2,11 +2,13 @@
 <view class="order flex-column">
   <view class="order-style flex-column">
     <view class="order-state flex-column">
-      <view class="order-state-title">订单已完成</view>
+      <view class="order-state-title" wx:if="{{orderDetail.status.value == 1}}">订单{{orderDetail.status.showText}}</view>
+      <view class="order-state-title" wx:if="{{orderDetail.status.value == 2}}">订单{{orderDetail.status.showText}}</view>
+      <view class="order-state-title" wx:if="{{orderDetail.status.value == 3}}">订单{{orderDetail.status.showText}}</view>
+      <view class="order-state-title" wx:if="{{orderDetail.status.value == 4}}">订单{{orderDetail.status.showText}}</view>
+      <view class="order-state-title" wx:if="{{orderDetail.status.value == 5}}">订单{{orderDetail.status.showText}}</view>
       <view class="order-state-text">感谢您对沪上阿姨的喜爱与支持,欢迎再度光临</view>
     </view>
-
-    <!-- 订单详情 -->
     <view class="order-details flex-column">
       <view class="content-hm flex-column">
         <view class="content-head flex-row">
@@ -14,18 +16,37 @@
         </view>
         <view class="content-middle flex-row">
           <view class="middle-it flex-row">
-            <image class="middle-img" src="/images/welfareMall/middle_img.png" />
-            <view class="middle-text">圣诞优惠券包</view>
+            <image class="middle-img" src="{{orderDetail.goodsList[0].fullCoverImg}}" />
+            <view class="middle-text">{{orderDetail.goodsList[0].activityName}}</view>
           </view>
           <view class="middle-num flex-column">
-            <view class="middle-num-money">¥0.0</view>
-            <view class="money-num-count">x1</view>
+            <view class="middle-num-money">¥{{orderDetail.payPriceFormatter}}</view>
+            <view class="money-num-count">x{{orderDetail.goodsList.length}}</view>
           </view>
         </view>
       </view>
+      <view class="content-payment flex-row">
+        <view class="content-payment-mode">支付方式</view>
+        <view class="content-payment-mode">微信支付</view>
+      </view>
       <view class="content-line"></view>
       <view class="content-lower flex-row" catchtap="getCompletion">
-        <view class="lower-total">共1件商品 合计¥9.9</view>
+        <view class="lower-total">共{{orderDetail.goodsList.length}}件商品 合计¥{{orderDetail.payPriceFormatter}}</view>
+      </view>
+    </view>
+    <view class="order-information flex-column">
+      <view class="order-information-code flex-row">
+        <view class="code-text">订单编号</view>
+        <view class="code-num">{{orderDetail.orderSn}}</view>
+      </view>
+      <view class="order-information-date flex-row">
+        <view class="date-text">交易时间</view>
+        <view class="date-time">{{orderDetail.payedAt}}</view>
+      </view>
+    </view>
+    <view class="order-rt flex-row">
+      <view class="order-refund flex-row">
+        <view class="lower-order-text">申请退款</view>
       </view>
     </view>
   </view>

+ 2 - 2
pages/welfareMall/personal/personal.wxss

@@ -30,7 +30,7 @@
 }
 
 .head-personal{
-  width: 100%;
+  width: 666rpx;
   height: 136rpx;
   justify-content: flex-start;
   margin-left: 35rpx;
@@ -84,7 +84,7 @@
 }
 
 .content{
-  width: 100%;
+  width: 750rpx;
   height: auto;
 }
 

+ 6 - 0
project.private.config.json

@@ -71,6 +71,12 @@
           "pathName": "pages/welfareMall/activityInfo/activityInfo",
           "query": "",
           "scene": null
+        },
+        {
+          "name": "pages/welfareMall/order/orderCompletion",
+          "pathName": "pages/welfareMall/order/orderCompletion",
+          "query": "ordersn=162787680070366",
+          "scene": null
         }
       ]
     }

+ 38 - 0
utils/util.js

@@ -100,6 +100,44 @@ function getQueryVariable(variable,query)
        return(false);
 }
 
+function parseTime(time, cFormat) {
+  if (arguments.length === 0 || !time) {
+    return null
+  }
+  const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
+  let date
+  if (typeof time === 'object') {
+    date = time
+  } else {
+    if ((typeof time === 'string')) {
+      if ((/^[0-9]+$/.test(time))) {
+        time = parseInt(time)
+      } else {
+        time = time.replace(new RegExp(/-/gm), '/')
+      }
+    }
+    if ((typeof time === 'number') && (time.toString().length === 10)) {
+      time = time * 1000
+    }
+    date = new Date(time)
+  }
+  const formatObj = {
+    y: date.getFullYear(),
+    m: date.getMonth() + 1,
+    d: date.getDate(),
+    h: date.getHours(),
+    i: date.getMinutes(),
+    s: date.getSeconds(),
+    a: date.getDay()
+  }
+  const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
+    const value = formatObj[key]
+    if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
+    return value.toString().padStart(2, '0')
+  })
+  return time_str
+}
+
 module.exports = {
   formatTime,
   sha1,