orderDetail.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view class="default_page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='我的订单' bgColor="transparent"></cus-header>
  4. <image class="top_bg" :src="imgBase+'order_detail_bg.png'" mode="widthFix"></image>
  5. <view class="top adf">
  6. <view class="top-left adfac">
  7. <image :src="imgBase+'order_detail_success.png'"></image>
  8. <view class="top-left-texts adffc">
  9. <view class="text">{{statusCfg[orderInfo.orderStatus]}}</view>
  10. <view class="text tip adfac" v-if="orderInfo.orderStatus===0">
  11. 剩余支付时间<text style="margin: 0 4rpx;"></text>
  12. <u-count-down :time="countDownTime" format="HH:mm:ss" autoStart @finish="finish"></u-count-down>,
  13. 超时将自动取消
  14. </view>
  15. <view class="text tip" v-else>{{statusTip[orderInfo.orderStatus]||''}}</view>
  16. </view>
  17. </view>
  18. <view class="top-right">¥{{orderInfo.payAmount||0}}</view>
  19. </view>
  20. <view class="form">
  21. <view class="form-item adfacjb">
  22. <view class="form-item-title">订单号</view>
  23. <view class="form-item-value">{{orderInfo.orderNo||''}}</view>
  24. </view>
  25. <view class="form-item adfacjb">
  26. <view class="form-item-title">订单类型</view>
  27. <view class="form-item-value">{{typeCfg[orderInfo.type]}} {{orderInfo.totalFrequency}}次</view>
  28. </view>
  29. <view class="form-item adfacjb">
  30. <view class="form-item-title">订单金额</view>
  31. <view class="form-item-value">¥{{orderInfo.payAmount||0}}</view>
  32. </view>
  33. <view class="form-item adfacjb">
  34. <view class="form-item-title">下单时间</view>
  35. <view class="form-item-value">{{orderInfo.createDate||''}}</view>
  36. </view>
  37. <view class="form-item adfacjb">
  38. <view class="form-item-title">有效期至</view>
  39. <view class="form-item-value">{{orderInfo.expirationTime||''}}</view>
  40. </view>
  41. </view>
  42. <view class="bottom adfacjb">
  43. <template v-if="orderInfo.orderStatus!=0">
  44. <view class="bottom-default" @click="buyAgain">再次购买</view>
  45. </template>
  46. <template v-else>
  47. <view class="bottom-default half qx" @click="orderCancel">取消订单</view>
  48. <view class="bottom-default half" @click="orderPay">立即支付</view>
  49. </template>
  50. </view>
  51. <WechatPay ref="wxPay" @confirmPay="toPay" @cancelPay="cancelPay"></WechatPay>
  52. </view>
  53. </template>
  54. <script>
  55. import WechatPay from '@/components/wechatPay/index.vue'
  56. export default {
  57. components:{ WechatPay },
  58. data(){
  59. return {
  60. id:'',
  61. orderInfo:null,
  62. countDown:15*60,//15分钟 单位秒
  63. countDownTime:0,
  64. statusCfg:{
  65. '-3':'已退款',
  66. '-2':'已取消',
  67. '-1':'已失效',
  68. '0':'待支付',
  69. '1':'已支付',
  70. '2':'已完成'
  71. },
  72. typeCfg:{
  73. '1':'基础版',
  74. '2':'专业版'
  75. },
  76. statusTip:{
  77. '1':'您的问卷已激活,开始PREILL评估',
  78. '2':'您的问卷已激活,开始PREILL评估',
  79. '-2':'您的订单已取消,可重新购买'
  80. }
  81. }
  82. },
  83. onLoad(options) {
  84. this.id = options.id;
  85. this.id&&this.getDetail()
  86. },
  87. methods:{
  88. getDetail(){
  89. this.$api.get(`/que/order/${this.id}`).then(({data:res})=>{
  90. if(res.code!==0) return this.$showToast(res.msg)
  91. this.orderInfo = res.data;
  92. if(this.orderInfo.orderStatus===0){
  93. let diff = new Date().getTime() - new Date(this.orderInfo.createDate).getTime();
  94. let diffS = Math.ceil(diff/1000)
  95. if(diffS<this.countDown) this.countDownTime = (this.countDown-diffS)*1000;
  96. }
  97. })
  98. },
  99. finish(){
  100. this.$api.put(`/que/order/closeOrder/${this.orderInfo.orderNo}`).then(({data:res})=>{
  101. this.$showToast('订单已取消')
  102. this.getDetail();
  103. })
  104. },
  105. buyAgain(){
  106. uni.navigateTo({
  107. url:'/pagesPublish/rechargeCenter'
  108. })
  109. },
  110. orderCancel(){
  111. uni.showModal({
  112. title:'温馨提示',
  113. content:'确定取消该订单?',
  114. success: (res) => {
  115. if(res.confirm){
  116. this.$api.put(`/que/order/closeOrder/${this.orderInfo.orderNo}`).then(({data:res})=>{
  117. if(res.code!==0) return this.$showToast(res.msg)
  118. this.$showToast('取消成功')
  119. setTimeout(()=>{
  120. uni.navigateBack()
  121. },1500)
  122. })
  123. }
  124. }
  125. })
  126. },
  127. orderPay(){
  128. this.$refs.wxPay.payShow = true;
  129. },
  130. toPay(){
  131. this.$api.post('/pay/createOrder',{
  132. orderNo:this.orderInfo.orderNo,
  133. openId:JSON.parse(uni.getStorageSync('userInfo')).openId
  134. }).then(({data:res})=>{
  135. if(!res.hasOwnProperty('paySign')) return this.$showToast('支付失败')
  136. this.$refs.wxPay.payShow = false;
  137. this.$wxPay(res).then(result => {
  138. uni.navigateTo({
  139. url:'/pagesPublish/payResult'
  140. })
  141. })
  142. })
  143. },
  144. }
  145. }
  146. </script>
  147. <style scoped lang="scss">
  148. .default_page{
  149. padding: 0 24rpx 192rpx;
  150. box-sizing: border-box;
  151. background: #F7F7F7;
  152. .top_bg{
  153. width: 100%;
  154. position: absolute;
  155. left: 0;
  156. top: 0;
  157. }
  158. .top{
  159. margin-top: 54rpx;
  160. padding: 0 24rpx;
  161. position: relative;
  162. justify-content: space-between;
  163. &-left{
  164. image{
  165. width: 69rpx;
  166. height: 69rpx;
  167. }
  168. &-texts{
  169. margin-left: 20rpx;
  170. .text{
  171. font-family: PingFang-SC, PingFang-SC;
  172. font-weight: bold;
  173. font-size: 40rpx;
  174. color: #002846;
  175. line-height: 40rpx;
  176. &.tip{
  177. font-family: PingFangSC, PingFang SC;
  178. font-weight: 400;
  179. font-size: 24rpx;
  180. color: #667E90;
  181. line-height: 26rpx;
  182. margin-top: 24rpx;
  183. }
  184. }
  185. }
  186. }
  187. &-right{
  188. font-family: PingFang-SC, PingFang-SC;
  189. font-weight: bold;
  190. font-size: 36rpx;
  191. color: #002846;
  192. line-height: 30rpx;
  193. text-align: right;
  194. }
  195. }
  196. .form{
  197. background: #FFFFFF;
  198. border-radius: 25rpx;
  199. margin-top: 54rpx;
  200. padding: 0 24rpx;
  201. position: relative;
  202. &-item{
  203. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #EFEFEF;
  204. padding: 34rpx 0;
  205. &-title{
  206. font-family: PingFangSC, PingFang SC;
  207. font-weight: 400;
  208. font-size: 30rpx;
  209. color: #002846;
  210. line-height: 30rpx;
  211. }
  212. &-value{
  213. font-family: PingFangSC, PingFang SC;
  214. font-weight: 400;
  215. font-size: 30rpx;
  216. color: #667E90;
  217. line-height: 30rpx;
  218. text-align: right;
  219. }
  220. }
  221. }
  222. .bottom{
  223. width: calc(100% - 88rpx);
  224. height: 88rpx;
  225. position: fixed;
  226. left: 44rpx;
  227. bottom: 54rpx;
  228. &-default{
  229. width: 100%;
  230. height: 88rpx;
  231. border: 1rpx solid #33A7A7;
  232. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);;
  233. border-radius: 44rpx;
  234. font-family: PingFang-SC, PingFang-SC;
  235. font-weight: bold;
  236. font-size: 32rpx;
  237. color: #FFFFFF;
  238. line-height: 88rpx;
  239. text-align: center;
  240. letter-spacing: 2rpx;
  241. &.half{
  242. width: calc(50% - 19rpx);
  243. }
  244. &.qx{
  245. color: #657588;
  246. background: #FFFFFF;
  247. border: 1rpx solid #CCD4DA;
  248. }
  249. }
  250. }
  251. }
  252. </style>