student_order_detail.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view>
  3. <view class="orderWrapper">
  4. <!-- 头部区域:订单号、头像 -->
  5. <view class="orderHead">
  6. <view class="orderHeadTitle">
  7. <view>
  8. <text>订单号</text>
  9. <text class="orderDetail">{{info.orderId}}</text>
  10. </view>
  11. <view>
  12. <text>对方</text>
  13. <text class="orderDetail">{{info.teacherName}}教员</text>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 中部区域:订单详情 -->
  18. <view class="orderMid">
  19. <view>
  20. <text>对方ID</text>
  21. <text class="orderDetail">{{info.teacherId}}</text>
  22. </view>
  23. <view>
  24. <text>需求号</text>
  25. <text class="courseNum" @click="toNeedDetail">{{info.requireId}}</text>
  26. </view>
  27. <view>
  28. <text>课程号</text>
  29. <text class="courseNum" @click="toCourseDetail">{{info.courseId}}</text>
  30. </view>
  31. <view>
  32. <text>需求金额</text>
  33. <text class="orderDetail">{{info.requireSalary/100}}</text>
  34. </view>
  35. </view>
  36. <view class="orderBottom">
  37. <view>
  38. <text>订单内容</text>
  39. <text class="orderDetail">{{info.requireDetail}}</text>
  40. </view>
  41. <view>
  42. <text>支付日期</text>
  43. <text class="orderDetail">{{info.datetime}}</text>
  44. </view>
  45. <view>
  46. <text>订单状态</text>
  47. <text class="orderPayStatus">{{info.status}}</text>
  48. </view>
  49. </view>
  50. <view class="payWrapper">
  51. <view class="pay" v-if="!payment">
  52. <view class="paidSucceed">
  53. <button class="payButton" @click="getPhone" type="primary">查看手机号</button>
  54. <button class="payButton" :disabled="buttonDisabled" @click="applyForRefund" type="warn">{{refundButton}}</button>
  55. </view>
  56. </view>
  57. </view>
  58. <view v-if="showPhone">
  59. <text>{{phone}}</text>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. export default {
  66. data() {
  67. return {
  68. buttonDisabled: true,
  69. timer: '',
  70. refundButton: '同意退款',
  71. phone: '',
  72. showPhone: false,
  73. disabled: false,
  74. minute: 0,
  75. second: 0,
  76. info: {},
  77. payment: false, //是否退款
  78. };
  79. },
  80. onLoad(option) {
  81. if (option.orderId !== undefined) {
  82. this.getOne(decodeURIComponent(option.orderId))
  83. }
  84. },
  85. methods: {
  86. toNeedDetail() {
  87. uni.navigateTo({
  88. url: '/subpkg/student/require/student_require_all_detail?requireId=' + encodeURIComponent(this.info.requireId)
  89. })
  90. },
  91. toCourseDetail() {
  92. uni.navigateTo({
  93. url: '/subpkg/teacher/course/teacher_course_all_detail?courseId=' + encodeURIComponent(this.info.courseId)
  94. })
  95. },
  96. // 申请退款
  97. async applyForRefund() {
  98. const queryObj = {
  99. orderNo: this.info.orderId,
  100. reason: '五天内试课不成功'
  101. }
  102. const {data: result} = await uni.$http.get('/payment/wx-pay/refunds', queryObj)
  103. if (result.message === '成功') {
  104. this.refundButton = '退款处理中'
  105. this.timer = setInterval(() => {
  106. this.queryIsRefundOrder()
  107. }, 1000)
  108. }
  109. },
  110. // 获取手机号
  111. async getPhone() {
  112. const {data: result} = await uni.$http.get('/ucenter/mini-program-openid-uid/getPhoneByUid', {uid: this.info.teacherId})
  113. this.phone = result.data.phone
  114. this.showPhone = true
  115. },
  116. // 获取订单信息
  117. async getOne(id) {
  118. const queryObj = {
  119. orderId: id
  120. }
  121. const {data: result} = await uni.$http.get('/payment/order-info/getOrderInfoByOrderId', queryObj)
  122. this.info = result.data.one
  123. if (this.info.isRefund === 1) this.buttonDisabled = false
  124. if (this.info.status === '已退款') this.payment = true
  125. },
  126. async queryIsRefundOrder() {
  127. const {data: result} = await uni.$http.get('/payment/order-info/queryIsRefundOrder', {orderId: this.info.orderId})
  128. if('已退款' === result.message) {
  129. this.showPhone = false
  130. clearInterval(this.timer)
  131. this.payment = true
  132. this.info.status = '已退款'
  133. uni.$showMsg('退款成功')
  134. }
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. /* 设置全局边距 */
  141. .orderWrapper{
  142. padding-left: 20rpx;
  143. /* background-color: yellowgreen; */
  144. }
  145. /* 头部区域 */
  146. .orderHead{
  147. display: flex;
  148. position: relative;
  149. height: 200rpx;
  150. padding-top: 20rpx;
  151. }
  152. /* 头像 */
  153. .headImg{
  154. width: 160rpx;
  155. height: 160rpx;
  156. border-radius: 30rpx;
  157. position: absolute;
  158. right: 30rpx;
  159. }
  160. .orderHeadTitle{
  161. display: flex;
  162. flex-direction: column;
  163. height: 80px;
  164. justify-content: space-around;
  165. }
  166. /* 设置内容样式 */
  167. .orderDetail,
  168. .courseNum,
  169. .orderPayStatus{
  170. margin-left: 20rpx;
  171. font-weight: bold;
  172. }
  173. .courseNum{
  174. color: #00B0F0;
  175. text-decoration: underline;
  176. }
  177. /* 支付状态字体样式 */
  178. .orderPayStatus{
  179. color: red;
  180. }
  181. /* 中部区域 */
  182. .orderMid{
  183. height: 220rpx;
  184. display: flex;
  185. flex-direction: column;
  186. justify-content: space-around;
  187. }
  188. /* 底部区域 */
  189. .orderBottom{
  190. margin-top: 40rpx;
  191. height: 260rpx;
  192. display: flex;
  193. flex-direction: column;
  194. justify-content: space-around;
  195. }
  196. /* 支付倒计时 */
  197. .orderPay{
  198. margin-top: 40rpx;
  199. display: flex;
  200. align-items: baseline;
  201. }
  202. /* 倒计时时间格式 */
  203. .orderPayTime{
  204. padding-left: 20rpx;
  205. font-weight: bold;
  206. font-size: 40rpx;
  207. color: red;
  208. }
  209. /* 提醒信息 */
  210. .warning{
  211. display: flex;
  212. justify-content: center;
  213. margin-top: 60rpx;
  214. }
  215. /* 提醒信息详情 */
  216. .warningDetail{
  217. width: 80%;
  218. display: flex;
  219. flex-direction: column;
  220. font-size: 44rpx;
  221. font-weight: bold;
  222. color: red;
  223. }
  224. /* 支付及查看信息按钮居中排列 */
  225. .payWrapper{
  226. display: flex;
  227. justify-content: center;
  228. }
  229. .payButton{
  230. border-radius: 30rpx;
  231. }
  232. .paidSucceed{
  233. display: flex;
  234. width: 100%;
  235. justify-content: space-around;
  236. }
  237. .pay{
  238. /* display: flex; */
  239. width: 100%;
  240. }
  241. </style>