student_order_detail.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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="payYesButton" @click="getPhone" type="primary">查看手机号</button>
  54. <button class="payNoButton" :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. <!-- 设置页面背景 -->
  140. <style lang="scss">
  141. page{
  142. height: 100%;
  143. // background-color: #FFF;
  144. }
  145. </style>
  146. <style lang="scss" scoped>
  147. /* 设置全局边距 */
  148. .orderWrapper{
  149. padding-left: 20rpx;
  150. /* background-color: yellowgreen; */
  151. }
  152. /* 头部区域 */
  153. .orderHead{
  154. display: flex;
  155. position: relative;
  156. height: 200rpx;
  157. padding-top: 20rpx;
  158. }
  159. /* 头像 */
  160. .headImg{
  161. width: 160rpx;
  162. height: 160rpx;
  163. border-radius: 30rpx;
  164. position: absolute;
  165. right: 30rpx;
  166. }
  167. .orderHeadTitle{
  168. display: flex;
  169. flex-direction: column;
  170. height: 80px;
  171. justify-content: space-around;
  172. }
  173. /* 设置内容样式 */
  174. .orderDetail,
  175. .courseNum,
  176. .orderPayStatus{
  177. margin-left: 20rpx;
  178. font-weight: bold;
  179. }
  180. .courseNum{
  181. color: #00B0F0;
  182. text-decoration: underline;
  183. }
  184. /* 支付状态字体样式 */
  185. .orderPayStatus{
  186. color: red;
  187. }
  188. /* 中部区域 */
  189. .orderMid{
  190. height: 220rpx;
  191. display: flex;
  192. flex-direction: column;
  193. justify-content: space-around;
  194. }
  195. /* 底部区域 */
  196. .orderBottom{
  197. margin-top: 40rpx;
  198. height: 260rpx;
  199. display: flex;
  200. flex-direction: column;
  201. justify-content: space-around;
  202. }
  203. /* 支付倒计时 */
  204. .orderPay{
  205. margin-top: 40rpx;
  206. display: flex;
  207. align-items: baseline;
  208. }
  209. /* 倒计时时间格式 */
  210. .orderPayTime{
  211. padding-left: 20rpx;
  212. font-weight: bold;
  213. font-size: 40rpx;
  214. color: red;
  215. }
  216. /* 提醒信息 */
  217. .warning{
  218. display: flex;
  219. justify-content: center;
  220. margin-top: 60rpx;
  221. }
  222. /* 提醒信息详情 */
  223. .warningDetail{
  224. width: 80%;
  225. display: flex;
  226. flex-direction: column;
  227. font-size: 44rpx;
  228. font-weight: bold;
  229. color: red;
  230. }
  231. /* 支付及查看信息按钮居中排列 */
  232. .payWrapper{
  233. display: flex;
  234. justify-content: center;
  235. }
  236. .payYesButton,
  237. .payNoButton{
  238. border-radius: 50rpx;
  239. color: white;
  240. }
  241. .payYesButton{
  242. background-color: #35b882;
  243. }
  244. .payNoButton{
  245. background-color: #3ed598;
  246. }
  247. .paidSucceed{
  248. display: flex;
  249. width: 100%;
  250. justify-content: space-around;
  251. }
  252. .pay{
  253. /* display: flex; */
  254. width: 100%;
  255. }
  256. </style>