orderItem.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. <template>
  2. <view class="order-row" @click="goToOrderDetail()">
  3. <view class="shop-info" v-if="orderData" @click="gotoShop()">
  4. <text class="iconfont icondianpu"></text>
  5. <text class="shop-name">{{orderData.supplierName}}</text>
  6. <text class="iconfont iconfangxiang"></text>
  7. <text class="order-type">{{getOrderType(orderData.orderStatus)}}</text>
  8. </view>
  9. <view class="goods-list" v-if="orderData">
  10. <view class="goods-row" v-for="(site, index) in orderData.products" :key="index">
  11. <cover-image class="goods-img" :src="site.imgUrl"></cover-image>
  12. <view class="goods-info">
  13. <view class="goods-name">{{site.productName}}</view>
  14. <view class="goods-type">
  15. 类型:{{site.productType == 1 ? '普通商品' : (site.productType == 2 ? '拍卖' : (site.productType == 3 ? '自助采摘' : '共享种植'))}}
  16. </view>
  17. <view class="goods-price-number">
  18. <text class="goods-unit">¥</text>
  19. <text class="goods-price">{{site.bizPrice}}</text>
  20. <text class="goods-number">x{{site.buyNum}}</text>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="pay-info">总价¥{{getAllPrice()}},实付¥{{orderData.paySum}}</view>
  26. <view class="handle-box" v-if="tabIndex > 1">
  27. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  28. v-if="tabIndex == 2" @click.stop="handleOrder(1)">取消订单</u-button>
  29. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  30. v-if="tabIndex == 2" @click.stop="handleOrder(2)">立即支付</u-button>
  31. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  32. v-if="tabIndex != 1 && tabIndex != 2" @click.stop="handleOrder(3)">申请售后</u-button>
  33. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  34. v-if="tabIndex == 3 && pickHandle" @click.stop="handleOrder(4)">自助采摘</u-button>
  35. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  36. v-if="tabIndex == 4" @click.stop="handleOrder(5)">确认收货</u-button>
  37. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  38. v-if="tabIndex == 4" @click.stop="handleOrder(6)">追踪物流</u-button>
  39. <u-button size="medium" :plain="true" type="success" shape="circle" :ripple="true" :hair-line="false" class="handle-button"
  40. v-if="tabIndex == 5 && orderData.evaluateStatus == 1" @click.stop="handleOrder(7)">评价</u-button>
  41. </view>
  42. <u-modal v-model="modalShow" :content="modalContent" @confirm="submitHandle" :async-close="true" :show-cancel-button="true"></u-modal>
  43. <u-top-tips ref="uTips"></u-top-tips>
  44. </view>
  45. </template>
  46. <script>
  47. const NET = require('@/utils/request')
  48. const API = require('@/config/api')
  49. export default {
  50. props: {
  51. tabIndex: {
  52. default: 1
  53. },
  54. orderData: {
  55. default: {
  56. auctionStatus: 0,
  57. orderId: 0,
  58. orderStatus: 0,
  59. evaluateReplyStatus: 0,
  60. nickname: '',
  61. payStatus: 0,
  62. paySum: 0,
  63. products: [{
  64. bizPrice: 0,
  65. buyNum: 0,
  66. imgUrl: '',
  67. originalPrice: 0,
  68. productId: 0,
  69. productName: '',
  70. productType: 0,
  71. shoppingcartId: 0,
  72. tenantCode: ''
  73. }],
  74. supplierName: '',
  75. tenantCode: ''
  76. }
  77. },
  78. },
  79. data() {
  80. return {
  81. pickHandle: false,
  82. modalShow: false,
  83. modalContent: '',
  84. handleType: '',
  85. }
  86. },
  87. onReady() {
  88. this.pickHandle = this.orderData.products.filter(site=> site.productType == 3).length > 0
  89. },
  90. methods: {
  91. // 跳转商铺
  92. gotoShop() {
  93. if (this.orderData.products.length) {
  94. uni.navigateTo({
  95. url: '/pagesGood/shopDetails?goodId=' + this.orderData.products[0].productId
  96. });
  97. }
  98. },
  99. // 获取订单总价
  100. getAllPrice() {
  101. let price = this.orderData.products.reduce((total, site) => {
  102. return total + site.bizPrice * site.buyNum
  103. }, 0)
  104. return price.toFixed(2)
  105. },
  106. // 获取订单类型
  107. getOrderType(type) {
  108. switch (type) {
  109. case 1:
  110. return '待付款'
  111. break;
  112. case 2:
  113. return '待发货'
  114. break;
  115. case 3:
  116. return '已发货'
  117. break;
  118. case 4:
  119. return '已收货'
  120. break;
  121. case 5:
  122. return '已完成'
  123. break;
  124. default:
  125. return '已取消'
  126. }
  127. },
  128. // 操作区分
  129. handleOrder(type) {
  130. if (type == 1 || type == 2 || type == 5) {
  131. this.modalContent = type == 1 ? '请确定是否取消订单' : (type == 2 ? '请确定是否立即支付' : '请确定是否确认收货')
  132. this.handleType = type
  133. this.modalShow = true
  134. } else if (type == 3) {
  135. // 申请售后
  136. NET.request(API.applyService, {
  137. tenantCode: this.orderData.tenantCode
  138. }, 'GET').then(res => {
  139. uni.makePhoneCall({
  140. phoneNumber: res.data.contactTel
  141. });
  142. }).catch(error => {
  143. this.$refs.uTips.show({
  144. title: error.data.msg,
  145. type: 'warning',
  146. })
  147. })
  148. } else if (type == 4) {
  149. // 自助采摘
  150. uni.navigateTo({
  151. url: '/pagesGood/pickVideo?tenantCode=' + this.orderData.tenantCode
  152. });
  153. } else if (type == 6) {
  154. // 追踪物流
  155. uni.navigateTo({
  156. url: '/pagesMain/logisticsDeatil?logisticCode=' + this.orderData.logisticsNum
  157. });
  158. } else if (type == 7) {
  159. // 评价
  160. uni.navigateTo({
  161. url: '/pagesMain/evaluateForm?orderId=' + this.orderData.orderId + '&tenantCode=' + this.orderData.tenantCode +
  162. '&productIds=' + this.orderData.products.map(site => {
  163. return site.productId
  164. }).join(',')
  165. });
  166. }
  167. },
  168. // 跳转订单详情
  169. goToOrderDetail() {
  170. uni.navigateTo({
  171. url: '/pagesMain/orderDetail?orderId=' + this.orderData.orderId + '&orderStatus=' + this.orderData.orderStatus
  172. });
  173. },
  174. // 状态流转
  175. submitHandle() {
  176. if (this.handleType == 1) {
  177. // 取消订单
  178. NET.request(API.cancelOrder, {
  179. orderId: this.orderData.orderId
  180. }, 'GET').then(res => {
  181. this.modalShow = false
  182. this.$emit('reasetList');
  183. this.$refs.uTips.show({
  184. title: '取消订单成功',
  185. type: 'success',
  186. })
  187. }).catch(error => {
  188. this.modalShow = false
  189. this.$refs.uTips.show({
  190. title: error.data.msg,
  191. type: 'warning',
  192. })
  193. })
  194. } else if (this.handleType == 2) {
  195. // 立即支付
  196. NET.request(API.payOrder, {
  197. mid: uni.getStorageSync("userData").userId,
  198. orderCode: this.orderData.orderCode,
  199. orderId: this.orderData.orderId,
  200. }, 'POST').then(res => {
  201. this.modalShow = false
  202. uni.requestPayment({
  203. provider: 'wxpay',
  204. timeStamp: res.data.timeStamp,
  205. nonceStr: res.data.nonceStr,
  206. package: res.data.packageValue,
  207. signType: res.data.signType,
  208. paySign: res.data.paySign,
  209. success: (payRes) => {
  210. console.log('success:' + JSON.stringify(payRes));
  211. uni.navigateTo({
  212. url: '/pagesMain/paySuccess'
  213. });
  214. },
  215. fail: (error) => {
  216. console.log('fail:' + JSON.stringify(error));
  217. this.$refs.uTips.show({
  218. title: '支付失败',
  219. type: 'warning',
  220. })
  221. }
  222. })
  223. }).catch(error => {
  224. this.modalShow = false
  225. this.$refs.uTips.show({
  226. title: error.data.msg,
  227. type: 'warning',
  228. })
  229. })
  230. } else if (this.handleType == 5) {
  231. // 确认收货
  232. NET.request(API.confirmOrder, {
  233. orderId: this.orderData.orderId
  234. }, 'GET').then(res => {
  235. this.modalShow = false
  236. this.$emit('reasetList');
  237. this.$refs.uTips.show({
  238. title: '确认收货成功',
  239. type: 'success',
  240. })
  241. }).catch(error => {
  242. this.modalShow = false
  243. this.$refs.uTips.show({
  244. title: error.data.msg,
  245. type: 'warning',
  246. })
  247. })
  248. }
  249. },
  250. }
  251. }
  252. </script>
  253. <style lang="less" scoped>
  254. .order-row {
  255. width: 100%;
  256. float: left;
  257. margin: 0 0 15px 0;
  258. background: #FFFFFF;
  259. border-radius: 10px;
  260. .shop-info {
  261. width: 100%;
  262. height: 48px;
  263. float: left;
  264. box-sizing: border-box;
  265. padding: 13px 15px 12px 15px;
  266. border-bottom: 1px solid #EEEEEE;
  267. line-height: 22px;
  268. .icondianpu {
  269. font-size: 22px;
  270. color: #333333;
  271. }
  272. .shop-name {
  273. font-size: 15px;
  274. font-family: PingFang SC;
  275. color: #333333;
  276. margin: 0 8px 0 10px;
  277. }
  278. .iconshangjia {
  279. font-size: 12px;
  280. color: #999999;
  281. }
  282. .order-type {
  283. float: right;
  284. font-size: 15px;
  285. font-family: PingFang SC;
  286. color: #52A63A;
  287. }
  288. }
  289. .goods-list {
  290. width: 100%;
  291. float: left;
  292. box-sizing: border-box;
  293. padding: 10px 15px 0 15px;
  294. .goods-row {
  295. width: 100%;
  296. height: 90px;
  297. float: left;
  298. display: flex;
  299. margin-bottom: 10px;
  300. .goods-img {
  301. width: 90px;
  302. height: 90px;
  303. border-radius: 5px;
  304. object-fit: cover;
  305. }
  306. .goods-info {
  307. width: calc(100% - 106px);
  308. height: 90px;
  309. margin-left: 16px;
  310. .goods-name {
  311. width: 100%;
  312. height: 36px;
  313. float: left;
  314. font-size: 14px;
  315. font-family: PingFang SC;
  316. color: #333333;
  317. line-height: 18px;
  318. overflow: hidden;
  319. text-overflow: ellipsis;
  320. display: -webkit-box;
  321. -webkit-line-clamp: 2;
  322. -webkit-box-orient: vertical;
  323. word-wrap: break-word;
  324. }
  325. .goods-type {
  326. height: 20px;
  327. float: left;
  328. background: #F0F0F0;
  329. border-radius: 4px;
  330. padding: 0 8px;
  331. margin: 6px 0;
  332. font-size: 10px;
  333. font-family: PingFang SC;
  334. color: #666666;
  335. line-height: 20px;
  336. }
  337. .goods-price-number {
  338. width: 100%;
  339. height: 20px;
  340. float: left;
  341. line-height: 20px;
  342. font-family: PingFang SC;
  343. color: #333333;
  344. .goods-unit {
  345. font-size: 12px;
  346. }
  347. .goods-price {
  348. font-size: 15px;
  349. margin-right: 6px;
  350. }
  351. .goods-number {
  352. font-size: 12px;
  353. }
  354. }
  355. }
  356. }
  357. }
  358. .pay-info {
  359. width: 100%;
  360. float: left;
  361. box-sizing: border-box;
  362. padding: 20px 15px 16px 15px;
  363. font-size: 12px;
  364. font-family: PingFang SC;
  365. color: #333333;
  366. line-height: 16px;
  367. text-align: right;
  368. }
  369. .handle-box {
  370. width: calc(100% - 30px);
  371. float: left;
  372. margin: 0 15px;
  373. box-sizing: border-box;
  374. padding: 10px 0 0 0;
  375. border-top: 1px solid #EEEEEE;
  376. text-align: right;
  377. .handle-button {
  378. color: #333333 !important;
  379. border-color: #BFBFBF !important;
  380. background-color: #FFFFFF !important;
  381. padding: 0;
  382. margin-left: 8px;
  383. margin-bottom: 10px;
  384. height: 30px;
  385. line-height: 30px;
  386. display: inline-block;
  387. }
  388. }
  389. }
  390. /deep/.u-size-medium {
  391. padding: 0 12px;
  392. }
  393. /deep/.u-round-circle {
  394. padding: 0 12px;
  395. }
  396. </style>