orderdetails.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="pages page-wrap">
  3. <view class="step-wrap" v-if="status == 0||status == 1||status == 2||status == 3">
  4. <view class="step-item" data-text="已拍下" :class="status == 0||status == 1||status == 2||status == 3?'active':''"></view>
  5. <view class="step-item" data-text="已付款" :class="status == 1||status == 2||status == 3?'active':''"></view>
  6. <view class="step-item" data-text="已发货" :class="status == 2||status == 3?'active':''"></view>
  7. <view class="step-item" data-text="交易成功" :class="status == 3?'active':''"></view>
  8. </view>
  9. <view class="status-wrap" v-if="status == 0">
  10. <view class="status-til" v-if="status == 0">等待付款</view>
  11. <view class="status-til" v-if="status == 1">待发货</view>
  12. <view class="status-til" v-if="status == 2">已发货</view>
  13. <view class="status-til" v-if="status == 3">已完成</view>
  14. <view class="status-til" v-if="status == 5">无效订单</view>
  15. <view class="status-con" v-if="status == 0">
  16. 如超时未付款,订单将 <br> 自动关闭
  17. </view>
  18. <view class="status-con" v-if="status == 2">
  19. {{logistics}}
  20. </view>
  21. <view class="status-icon"><text class="iconfont iconhoutui"></text></view>
  22. </view>
  23. <view class="status-common" v-if="status == 1">
  24. 等待发货
  25. </view>
  26. <view class="status-common delivery-company" v-if="status == 2">
  27. 您的快递单号为:{{item.deliverySn}}
  28. <view class="company" @click="gocheck(item.deliverySn)">{{item.deliveryCompany}}</view>
  29. </view>
  30. <view class="status-common" v-if="status == 4">
  31. <!-- 因交易超时,系统关闭了该笔交易 -->
  32. 订单已关闭
  33. </view>
  34. <!-- status end -->
  35. <view class="bill-info">
  36. <view class="bill-product" @click="jumpDetails(orderItemList.productId)">
  37. <view class="bill-product-imgwrap">
  38. <image :src="orderItemList.productPic" class="bill-product-img" mode="aspectFill"></image>
  39. </view>
  40. <view class="bill-product-info">
  41. <view class="bill-product-name">{{orderItemList.productName}}</view>
  42. <view class="bill-product-price-wrap">
  43. <view class="left">
  44. ¥
  45. <text class="bill-product-price">{{orderItemList.productPrice}}</text>
  46. <text class="bill-product-unit" v-if="orderItemList.productUnit">/{{orderItemList.productUnit}}</text>
  47. </view>
  48. <view class="bill-product-number">
  49. X {{orderItemList.productQuantity}}
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- bill-product end -->
  55. <view class="form-item">
  56. <view class="form-item-til">商品总额</view>
  57. <view class="form-item-con amount">
  58. ¥ {{ orderItemList.productPrice*orderItemList.productQuantity }}
  59. </view>
  60. </view>
  61. <view class="form-item">
  62. <view class="form-item-til">配送方式</view>
  63. <view class="form-item-con">
  64. 普通快递
  65. </view>
  66. </view>
  67. <view class="form-item">
  68. <view class="form-item-til">运费</view>
  69. <view class="form-item-con">
  70. ¥ 0
  71. </view>
  72. </view>
  73. </view>
  74. <!-- bill-info end -->
  75. <view class="addr">
  76. <view class="addr-up">
  77. <text class="addr-name">{{ item.receiverName }}</text>
  78. <text class="addr-phone">{{ item.receiverPhone }}</text>
  79. </view>
  80. <view class="addr-theaddr">
  81. 收货地址:
  82. {{item.receiverProvince}}
  83. {{item.receiverCity}}
  84. {{item.receiverRegion}}
  85. {{item.receiverDetailAddress}}
  86. </view>
  87. </view>
  88. <!-- addr end -->
  89. <view class="order-info">
  90. <view class="order-info-til">订单信息</view>
  91. <view class="order-info-item">订单编号:{{item.orderSn}}</view>
  92. <view class="order-info-item">创建时间:{{item.createTime | formatDateTime}}</view>
  93. <view class="order-info-item" v-if="item.paymentTime">支付时间:{{item.paymentTime | formatDateTime}}</view>
  94. <view class="order-info-item" v-if="item.deliveryTime">发货时间:{{item.deliveryTime | formatDateTime}}</view>
  95. <view class="order-info-item" v-if="item.receiveTime">确收时间:{{item.receiveTime | formatDateTime}}</view>
  96. <view class="order-info-call" @click="callnumber" v-if="helpphone">联系客服</view>
  97. </view>
  98. <!-- order-info end -->
  99. <view class="bottom-flex-btn-wrap orderdetails" v-if="status == 0">
  100. <view class="bottom-flex-btn-content">
  101. <button type="default" class="bottom-flex-btn" @click="cancelOrder">取消订单</button>
  102. <button type="default" class="bottom-flex-btn primary" @click="pay">我要付款</button>
  103. </view>
  104. </view>
  105. <view class="bottom-flex-btn-wrap orderdetails" v-if="status == 2">
  106. <view class="bottom-flex-btn-content">
  107. <button type="default" class="bottom-flex-btn primary" @click="received">确认收货</button>
  108. </view>
  109. </view>
  110. <!-- bottom-flex-btn-wrap end -->
  111. <uni-popup ref="popup" type="dialog">
  112. <uni-popup-dialog type="info" :content="popupContent" :duration="2000" :before-close="true" @close="closepopup" @confirm="confirmpopup"></uni-popup-dialog>
  113. </uni-popup>
  114. </view>
  115. </template>
  116. <script>
  117. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  118. import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue';
  119. export default {
  120. components: {
  121. uniPopup,
  122. uniPopupDialog,
  123. },
  124. data() {
  125. return {
  126. token:'',
  127. tokenhead:'',
  128. params: {
  129. orderid:'',
  130. },
  131. item:{},
  132. orderItemList:{},
  133. status:null,
  134. helpphone:null,
  135. logistics:'暂时无法获取物流信息',
  136. popupContent:'',
  137. popupType:'',
  138. }
  139. },
  140. onShow() {
  141. let serf = this;
  142. },
  143. onLoad(option) {
  144. this.params.orderid = option.orderid;
  145. let self = this;
  146. uni.getStorage({
  147. key:'token',
  148. success: function (res) {
  149. self.token = res.data;
  150. // console.log(res.data);
  151. }
  152. });
  153. uni.getStorage({
  154. key:'tokenhead',
  155. success: function (res) {
  156. self.tokenhead = res.data;
  157. // console.log(res.data);
  158. }
  159. });
  160. this.getdetails();
  161. },
  162. methods: {
  163. getdetails(){
  164. this.$api.http.get(this.config.apiBaseurl + '/order/detail/'+this.params.orderid,{
  165. header: {
  166. Accept:'application/json',
  167. Authorization: 'Bearer '+ this.token, //注意Bearer后面有一空格
  168. },
  169. }).then(res => {
  170. this.item = res.data.data;
  171. this.orderItemList = res.data.data.orderItemList[0];
  172. // console.log('this.orderItemList',this.orderItemList);
  173. this.status = res.data.data.status;
  174. // console.log('status',this.status)
  175. console.log('res',JSON.parse(JSON.stringify(this.item)))
  176. }).catch(err =>{
  177. console.log('err',err)
  178. });
  179. },
  180. cancelOrder(){
  181. this.$refs.popup.open();
  182. this.popupContent = '确认取消此订单吗?';
  183. this.popupType = 'cancel';
  184. },
  185. received(){
  186. this.$refs.popup.open();
  187. this.popupContent = '确认收货?';
  188. this.popupType = 'received';
  189. },
  190. closepopup(done){
  191. done()
  192. },
  193. confirmpopup(done,value){
  194. if(this.popupType == 'cancel'){
  195. this.$api.http.post(this.config.apiBaseurl + '/order/cancelUserOrder/?orderId='+this.item.id,{},{
  196. header: {
  197. Accept:'application/json',
  198. Authorization: 'Bearer '+ this.token, //注意Bearer后面有一空格
  199. },
  200. }).then(res => {
  201. this.getdetails();
  202. // console.log('res',res)
  203. }).catch(err =>{
  204. console.log('err',err)
  205. });
  206. }else if(this.popupType == 'received'){
  207. this.$api.http.post(this.config.apiBaseurl + '/order/confirmReceiveOrder/?orderId='+this.item.id,{},{
  208. header: {
  209. Accept:'application/json',
  210. Authorization: 'Bearer '+ this.token, //注意Bearer后面有一空格
  211. },
  212. }).then(res => {
  213. this.getdetails();
  214. // console.log('res',res)
  215. }).catch(err =>{
  216. console.log('err',err)
  217. });
  218. }
  219. done()
  220. },
  221. pay(){
  222. let userInfo = uni.getStorageSync("userInfo");
  223. let params = {
  224. orderId:this.item.id,
  225. payType:this.item.payType,
  226. openid:userInfo.wxUsers.openid,
  227. // "tradeType":"test"
  228. }
  229. this.$pay.wxPay(params).then(res =>{
  230. this.getdetails();
  231. // console.log('payres',res);
  232. }).catch(err =>{console.log('err',err);});
  233. },
  234. //打电话
  235. callnumber(number){
  236. if(!this.helpphone){
  237. uni.showToast({
  238. icon:'none',
  239. mask:true,
  240. title:`暂时没有客服`,
  241. duration: 2000
  242. });
  243. return;
  244. };
  245. uni.makePhoneCall({
  246. phoneNumber: this.helpphone
  247. });
  248. },
  249. //产品跳转链接
  250. jumpDetails(id){
  251. uni.navigateTo({
  252. url:`/pages/product/product?id=${id}`,
  253. fail(err) {
  254. console.log(err)
  255. }
  256. })
  257. },
  258. // 查快递
  259. gocheck(id){
  260. uni.setClipboardData({
  261. data: id
  262. });
  263. window.location.assign('https://m.kuaidi100.com/');
  264. }
  265. }
  266. }
  267. </script>
  268. <style scoped>
  269. @import url("./orderdetails.css");
  270. </style>