orderDetail.vue 7.4 KB

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