orderItem.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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" @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.evaluateReplyStatus == 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. }
  76. },
  77. },
  78. data() {
  79. return {
  80. modalShow: false,
  81. modalContent: '',
  82. handleType: '',
  83. }
  84. },
  85. onLoad() {},
  86. methods: {
  87. // 跳转商铺
  88. gotoShop() {
  89. if (this.orderData.products.length) {
  90. uni.navigateTo({
  91. url: '/pagesGood/shopDetails?goodId=' + this.orderData.products[0].productId
  92. });
  93. }
  94. },
  95. // 获取订单总价
  96. getAllPrice() {
  97. let price = this.orderData.products.reduce((total, site) => {
  98. return total + site.bizPrice * site.buyNum
  99. }, 0)
  100. return price.toFixed(2)
  101. },
  102. // 获取订单类型
  103. getOrderType(type) {
  104. switch (type) {
  105. case 1:
  106. return '待付款'
  107. break;
  108. case 2:
  109. return '待发货'
  110. break;
  111. case 3:
  112. return '已发货'
  113. break;
  114. case 4:
  115. return '已收货'
  116. break;
  117. case 5:
  118. return '已完成'
  119. break;
  120. default:
  121. return '已取消'
  122. }
  123. },
  124. // 操作区分
  125. handleOrder(type) {
  126. if (type == 1 || type == 2 || type == 5) {
  127. this.modalContent = type == 1 ? '请确定是否取消订单' : (type == 2 ? '请确定是否立即支付' : '请确定是否确认收货')
  128. this.handleType = type
  129. this.modalShow = true
  130. } else if (type == 3) {
  131. // 申请售后
  132. NET.request(API.applyService, {
  133. tenantCode: this.orderData.tenantCode
  134. }, 'GET').then(res => {
  135. uni.makePhoneCall({
  136. phoneNumber: res.data.contactTel
  137. });
  138. }).catch(error => {
  139. this.$refs.uTips.show({
  140. title: error.data.msg,
  141. type: 'warning',
  142. })
  143. })
  144. } else if (type == 4) {
  145. // 自助采摘
  146. uni.navigateTo({
  147. url: '/pagesGood/pickVideo?orderId=' + this.orderData.orderId
  148. });
  149. } else if (type == 6) {
  150. // 追踪物流
  151. uni.navigateTo({
  152. url: '/pagesMain/logisticsDeatil?logisticCode=' + this.orderData.logisticCode
  153. });
  154. } else if (type == 7) {
  155. // 评价
  156. uni.navigateTo({
  157. url: '/pagesMain/evaluateForm?orderId=' + this.orderData.orderId + '&tenantCode=' + this.orderData.tenantCode +
  158. '&productIds=' + this.orderData.products.map(site => {
  159. return site.productId
  160. }).join(',')
  161. });
  162. }
  163. },
  164. // 跳转订单详情
  165. goToOrderDetail() {
  166. uni.navigateTo({
  167. url: '/pagesMain/orderDetail?orderId=' + this.orderData.orderId + '&orderStatus=' + this.orderData.orderStatus
  168. });
  169. },
  170. // 状态流转
  171. submitHandle() {
  172. if (this.handleType == 1) {
  173. // 取消订单
  174. NET.request(API.cancelOrder, {
  175. orderId: this.orderData.orderId
  176. }, 'GET').then(res => {
  177. this.modalShow = false
  178. this.$emit('reasetList');
  179. this.$refs.uTips.show({
  180. title: '取消订单成功',
  181. type: 'success',
  182. })
  183. }).catch(error => {
  184. this.modalShow = false
  185. this.$refs.uTips.show({
  186. title: error.data.msg,
  187. type: 'warning',
  188. })
  189. })
  190. } else if (this.handleType == 2) {
  191. // 立即支付
  192. this.modalShow = false
  193. } else if (this.handleType == 5) {
  194. // 确认收货
  195. NET.request(API.confirmOrder, {
  196. orderId: this.orderData.orderId
  197. }, 'GET').then(res => {
  198. this.modalShow = false
  199. this.$emit('reasetList');
  200. this.$refs.uTips.show({
  201. title: '确认收货成功',
  202. type: 'success',
  203. })
  204. }).catch(error => {
  205. this.modalShow = false
  206. this.$refs.uTips.show({
  207. title: error.data.msg,
  208. type: 'warning',
  209. })
  210. })
  211. }
  212. },
  213. }
  214. }
  215. </script>
  216. <style lang="less" scoped>
  217. .order-row {
  218. width: 100%;
  219. float: left;
  220. margin: 0 0 15px 0;
  221. background: #FFFFFF;
  222. border-radius: 10px;
  223. .shop-info {
  224. width: 100%;
  225. height: 48px;
  226. float: left;
  227. box-sizing: border-box;
  228. padding: 13px 15px 12px 15px;
  229. border-bottom: 1px solid #EEEEEE;
  230. line-height: 22px;
  231. .icondianpu {
  232. font-size: 22px;
  233. color: #333333;
  234. }
  235. .shop-name {
  236. font-size: 15px;
  237. font-family: PingFang SC;
  238. color: #333333;
  239. margin: 0 8px 0 10px;
  240. }
  241. .iconshangjia {
  242. font-size: 12px;
  243. color: #999999;
  244. }
  245. .order-type {
  246. float: right;
  247. font-size: 15px;
  248. font-family: PingFang SC;
  249. color: #52A63A;
  250. }
  251. }
  252. .goods-list {
  253. width: 100%;
  254. float: left;
  255. box-sizing: border-box;
  256. padding: 10px 15px 0 15px;
  257. .goods-row {
  258. width: 100%;
  259. height: 90px;
  260. float: left;
  261. display: flex;
  262. margin-bottom: 10px;
  263. .goods-img {
  264. width: 90px;
  265. height: 90px;
  266. border-radius: 5px;
  267. object-fit: cover;
  268. }
  269. .goods-info {
  270. width: calc(100% - 106px);
  271. height: 90px;
  272. margin-left: 16px;
  273. .goods-name {
  274. width: 100%;
  275. height: 36px;
  276. float: left;
  277. font-size: 14px;
  278. font-family: PingFang SC;
  279. color: #333333;
  280. line-height: 18px;
  281. overflow: hidden;
  282. text-overflow: ellipsis;
  283. display: -webkit-box;
  284. -webkit-line-clamp: 2;
  285. -webkit-box-orient: vertical;
  286. word-wrap: break-word;
  287. }
  288. .goods-type {
  289. height: 20px;
  290. float: left;
  291. background: #F0F0F0;
  292. border-radius: 4px;
  293. padding: 0 8px;
  294. margin: 6px 0;
  295. font-size: 10px;
  296. font-family: PingFang SC;
  297. color: #666666;
  298. line-height: 20px;
  299. }
  300. .goods-price-number {
  301. width: 100%;
  302. height: 20px;
  303. float: left;
  304. line-height: 20px;
  305. font-family: PingFang SC;
  306. color: #333333;
  307. .goods-unit {
  308. font-size: 12px;
  309. }
  310. .goods-price {
  311. font-size: 15px;
  312. margin-right: 6px;
  313. }
  314. .goods-number {
  315. font-size: 12px;
  316. }
  317. }
  318. }
  319. }
  320. }
  321. .pay-info {
  322. width: 100%;
  323. float: left;
  324. box-sizing: border-box;
  325. padding: 20px 15px 16px 15px;
  326. font-size: 12px;
  327. font-family: PingFang SC;
  328. color: #333333;
  329. line-height: 16px;
  330. text-align: right;
  331. }
  332. .handle-box {
  333. width: calc(100% - 30px);
  334. height: 51px;
  335. float: left;
  336. margin: 0 15px;
  337. box-sizing: border-box;
  338. padding: 10px 0;
  339. border-top: 1px solid #EEEEEE;
  340. text-align: right;
  341. .handle-button {
  342. color: #333333 !important;
  343. border-color: #BFBFBF !important;
  344. background-color: #FFFFFF !important;
  345. padding: 0 16px;
  346. margin-left: 8px;
  347. height: 30px;
  348. line-height: 30px;
  349. }
  350. }
  351. }
  352. </style>