小程序端工程代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

303 lines
10 KiB

  1. <template>
  2. <view class="my-order" ref="container">
  3. <view class="header bg-color-red">
  4. <view class="picTxt acea-row row-between-wrapper">
  5. <view class="text">
  6. <view class="name">订单信息</view>
  7. <view>累计订单{{ orderData.orderCount || 0 }} 总消费{{ orderData.sumPrice || 0 }}</view>
  8. </view>
  9. </view>
  10. </view>
  11. <view class="nav acea-row row-around">
  12. <view class="item" :class="{ on: type === 0 }" @click="changeType(0)">
  13. <view>待付款</view>
  14. <view class="num">{{ orderData.unpaidCount || 0 }}</view>
  15. </view>
  16. <view class="item" :class="{ on: type === 1 }" @click="changeType(1)">
  17. <view>待发货</view>
  18. <view class="num">{{ orderData.unshippedCount || 0 }}</view>
  19. </view>
  20. <view class="item" :class="{ on: type === 2 }" @click="changeType(2)">
  21. <view>待收货</view>
  22. <view class="num">{{ orderData.receivedCount || 0 }}</view>
  23. </view>
  24. <view class="item" :class="{ on: type === 3 }" @click="changeType(3)">
  25. <view>待评价</view>
  26. <view class="num">{{ orderData.evaluatedCount || 0 }}</view>
  27. </view>
  28. <view class="item" :class="{ on: type === 4 }" @click="changeType(4)">
  29. <view>已完成</view>
  30. <view class="num">{{ orderData.completeCount || 0 }}</view>
  31. </view>
  32. </view>
  33. <view class="list">
  34. <view class="item" v-for="(order, orderListIndex) in orderList" :key="orderListIndex">
  35. <view class="title acea-row row-between-wrapper">
  36. <view class="acea-row row-middle">
  37. <span class="sign cart-color acea-row row-center-wrapper" v-if="order.combinationId > 0">拼团</span>
  38. <span class="sign cart-color acea-row row-center-wrapper" v-if="order.seckillId > 0">秒杀</span>
  39. <span class="sign cart-color acea-row row-center-wrapper" v-if="order.bargainId > 0">砍价</span>
  40. <span class="sign cart-color acea-row row-center-wrapper" v-if="order.storeId > 0">门店</span>
  41. {{ order.createTime }}
  42. </view>
  43. <view class="font-color-red">{{ getStatus(order) }}</view>
  44. </view>
  45. <view @click="goOrderDetails(order)">
  46. <view class="item-info acea-row row-between row-top" v-for="(cart, cartInfoIndex) in order.cartInfo" :key="cartInfoIndex">
  47. <view class="pictrue">
  48. <image :src="cart.productInfo.image" @click.stop="$yrouter.push({ path: '/pages/shop/GoodsCon/index', query: { id: cart.productInfo.id } })" v-if="cart.combinationId === 0 && cart.bargainId === 0 && cart.seckillId === 0" />
  49. <image
  50. :src="cart.productInfo.image"
  51. @click.stop="
  52. $yrouter.push({
  53. path: '/pages/activity/GroupDetails/index',
  54. query: { id: cart.combinationId },
  55. })
  56. "
  57. v-else-if="cart.combinationId > 0"
  58. />
  59. <image
  60. :src="cart.productInfo.image"
  61. @click.stop="
  62. $yrouter.push({
  63. path: '/pages/activity/DargainDetails/index',
  64. query: { id: cart.bargainId },
  65. })
  66. "
  67. v-else-if="cart.bargainId > 0"
  68. />
  69. <image
  70. :src="cart.productInfo.image"
  71. @click.stop="
  72. $yrouter.push({
  73. path: '/pages/activity/SeckillDetails/index',
  74. query: { id: cart.seckillId },
  75. })
  76. "
  77. v-else-if="cart.seckillId > 0"
  78. />
  79. </view>
  80. <view class="text acea-row row-between">
  81. <view class="name line2">{{ cart.productInfo.storeName }}</view>
  82. <view class="money">
  83. <view v-if="order.payType != 'integral'"> {{ cart.productInfo.attrInfo ? cart.productInfo.attrInfo.price : cart.productInfo.price }} </view>
  84. <view v-if="order.payType == 'integral'"> {{ order.payIntegral }}积分 </view>
  85. <view>x{{ cart.cartNum }}</view>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="totalPrice">
  91. {{ order.cartInfo.length || 0 }}件商品总金额
  92. <text class="money font-color-red" v-if="order.payType != 'integral'">{{ order.payPrice }}</text>
  93. <text class="money font-color-red" v-if="order.payType == 'integral'">{{ order.payIntegral }}积分</text>
  94. </view>
  95. <view class="bottom acea-row row-right row-middle">
  96. <template v-if="order._status._type == 0">
  97. <view class="bnt cancelBnt" @click="cancelOrder(order)">取消订单</view>
  98. <view class="bnt bg-color-red" @click="goOrderDetails(order)">立即付款</view>
  99. </template>
  100. <template v-if="order._status._type == 1 || order._status._type == 9">
  101. <view class="bnt bg-color-red" @click="goOrderDetails(order)">查看详情</view>
  102. </template>
  103. <template v-if="order._status._type == 2">
  104. <view class="bnt default" @click="goLogistics(order)">查看物流</view>
  105. <view class="bnt bg-color-red" @click="takeOrder(order)">确认收货</view>
  106. </template>
  107. <template v-if="order._status._type == 3">
  108. <!--<view-->
  109. <!--class="bnt default"-->
  110. <!--@click="-->
  111. <!--$yrouter.push({ path: '/pages/order/Logistics/index',query:{id:order.orderId}})-->
  112. <!--"-->
  113. <!--v-if="order.deliveryType == 'express'"-->
  114. <!--&gt;-->
  115. <!--查看物流-->
  116. <!--</view>-->
  117. <view class="bnt bg-color-red" @click="goOrderDetails(order)">去评价</view>
  118. </template>
  119. <template v-if="order._status._type === 4">
  120. <view class="bnt bg-color-red" @click="goOrderDetails(order)">查看订单</view>
  121. </template>
  122. </view>
  123. </view>
  124. </view>
  125. <view class="noCart" v-if="orderList.length === 0 && page > 1">
  126. <view class="pictrue">
  127. <image :src="`${$VUE_APP_RESOURCES_URL}/images/noOrder.png`" />
  128. </view>
  129. </view>
  130. <Loading :loaded="loaded" :loading="loading"></Loading>
  131. <Payment v-model="pay" :types="payType" @checked="toPay" :balance="userInfo.nowMoney"></Payment>
  132. </view>
  133. </template>
  134. <script>
  135. import { getOrderData, getOrderList } from '@/api/order'
  136. import { cancelOrderHandle, payOrderHandle, takeOrderHandle } from '@/libs/order'
  137. import Loading from '@/components/Loading'
  138. import Payment from '@/components/Payment'
  139. import DataFormat from '@/components/DataFormat'
  140. import { mapGetters } from 'vuex'
  141. import { isWeixin, dataFormat } from '@/utils'
  142. const STATUS = ['待付款', '待发货', '待收货', '待评价', '已完成', '', '', '', '', '待付款']
  143. const NAME = 'MyOrder'
  144. export default {
  145. name: NAME,
  146. data() {
  147. return {
  148. offlinePayStatus: 2,
  149. orderData: {},
  150. type: '',
  151. page: 1,
  152. limit: 20,
  153. loaded: false,
  154. loading: false,
  155. orderList: [],
  156. pay: false,
  157. payType: ['yue', 'weixin'],
  158. from: this.$deviceType,
  159. }
  160. },
  161. components: {
  162. Loading,
  163. Payment,
  164. DataFormat,
  165. },
  166. computed: mapGetters(['userInfo']),
  167. onShow: function() {
  168. console.log(this)
  169. this.type = parseInt(this.$yroute.query.type) || 0
  170. this.changeType(this.type)
  171. this.getOrderData()
  172. this.getOrderList()
  173. },
  174. onHide: function() {
  175. this.orderList = []
  176. this.page = 1
  177. this.limit = 20
  178. this.loaded = false
  179. this.loading = false
  180. },
  181. methods: {
  182. goLogistics(order) {
  183. this.$yrouter.push({
  184. path: '/pages/order/Logistics/index',
  185. query: { id: order.orderId },
  186. })
  187. },
  188. goOrderDetails(order) {
  189. this.$yrouter.push({
  190. path: '/pages/order/OrderDetails/index',
  191. query: { id: order.orderId },
  192. })
  193. },
  194. dataFormat,
  195. setOfflinePayStatus: function(status) {
  196. var that = this
  197. that.offlinePayStatus = status
  198. if (status === 1) {
  199. if (that.payType.indexOf('offline') < 0) {
  200. that.payType.push('offline')
  201. }
  202. }
  203. },
  204. getOrderData() {
  205. getOrderData().then(res => {
  206. this.orderData = res.data
  207. })
  208. },
  209. takeOrder(order) {
  210. takeOrderHandle(order.orderId).finally(() => {
  211. this.reload()
  212. this.getOrderData()
  213. })
  214. },
  215. reload() {
  216. this.changeType(this.type)
  217. },
  218. changeType(type) {
  219. this.type = type
  220. this.orderList = []
  221. this.page = 1
  222. this.loaded = false
  223. this.loading = false
  224. this.getOrderList()
  225. },
  226. getOrderList() {
  227. if (this.loading || this.loaded) return
  228. this.loading = true
  229. const { page, limit, type } = this
  230. getOrderList({
  231. page,
  232. limit,
  233. type,
  234. }).then(res => {
  235. this.orderList = this.orderList.concat(res.data)
  236. this.page++
  237. this.loaded = res.data.length < this.limit
  238. this.loading = false
  239. })
  240. },
  241. getStatus(order) {
  242. return STATUS[order._status._type]
  243. },
  244. cancelOrder(order) {
  245. cancelOrderHandle(order.orderId)
  246. .then(() => {
  247. this.getOrderData()
  248. this.orderList.splice(this.orderList.indexOf(order), 1)
  249. })
  250. .catch(() => {
  251. this.reload()
  252. })
  253. },
  254. paymentTap: function(order) {
  255. var that = this
  256. if (!(order.combinationId > 0 || order.bargainId > 0 || order.seckillId > 0)) {
  257. that.setOfflinePayStatus(order.offlinePayStatus)
  258. }
  259. this.pay = true
  260. this.toPay = type => {
  261. payOrderHandle(order.orderId, type, that.from)
  262. .then(() => {
  263. const type = parseInt(this.$yroute.query.type) || 0
  264. that.changeType(type)
  265. that.getOrderData()
  266. })
  267. .catch(() => {
  268. const type = parseInt(that.$yroute.query.type) || 0
  269. that.changeType(type)
  270. that.getOrderData()
  271. })
  272. }
  273. },
  274. toPay() {},
  275. },
  276. mounted() {},
  277. onReachBottom() {
  278. !this.loading && this.getOrderList()
  279. },
  280. }
  281. </script>
  282. <style scoped lang="less">
  283. .noCart {
  284. margin-top: 0.17 * 100rpx;
  285. padding-top: 0.1 * 100rpx;
  286. }
  287. .noCart .pictrue {
  288. width: 4 * 100rpx;
  289. height: 3 * 100rpx;
  290. overflow: hidden;
  291. margin: 0.7 * 100rpx auto 0.5 * 100rpx auto;
  292. }
  293. .noCart .pictrue image {
  294. width: 4 * 100rpx;
  295. height: 3 * 100rpx;
  296. }
  297. </style>