order_detail.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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.studentName}}学员</text>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 中部区域:订单详情 -->
  18. <view class="orderMid">
  19. <view>
  20. <text>对方ID</text>
  21. <text class="orderDetail">{{info.studentId}}</text>
  22. </view>
  23. <view>
  24. <text>需求号</text>
  25. <text class="courseNum" bindtap="toNeedDetail">{{info.requireId}}</text>
  26. </view>
  27. <view>
  28. <text>课程号</text>
  29. <text class="courseNum" bindtap="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 v-if="countDown">
  51. <uni-countdown :font-size="30" :showDay="false" :hour="0" :minute="minute" :second="second" color="#FFFFFF" background-color="red" />
  52. </view>
  53. <view class="payWrapper">
  54. <view class="paidSucceed" v-if="!pay">
  55. <button :disabled="disabled" type="primary" style="border-radius: 20%;" @click="paymentButton">{{payment}}</button>
  56. </view>
  57. <view class="pay" v-if="observed">
  58. <view class="paidSucceed">
  59. <button class="payButton" @click="getPhone" type="primary">查看手机号</button>
  60. <button class="payButton" :disabled="buttonDisabled" @click="applyForRefund" type="warn">{{refundButton}}</button>
  61. </view>
  62. </view>
  63. </view>
  64. <view v-if="showPhone">
  65. <text>{{phone}}</text>
  66. </view>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. export default {
  72. data() {
  73. return {
  74. time: 0,
  75. observed: false,
  76. buttonDisabled: false,
  77. timer: '',
  78. refundButton: '申请退款',
  79. phone: '',
  80. showPhone: false,
  81. countDown: true,
  82. payment: '教员支付',
  83. disabled: false,
  84. minute: 0,
  85. second: 0,
  86. info: {},
  87. pay: false, //是否支付
  88. };
  89. },
  90. onLoad(option) {
  91. if (option.orderId !== undefined) {
  92. this.getOne(option.orderId)
  93. this.getCountDown(option.orderId)
  94. }
  95. },
  96. methods: {
  97. // 申请退款
  98. async applyForRefund() {
  99. this.buttonDisabled = true
  100. const queryObj = {
  101. studentId: this.info.studentId,
  102. orderId: this.info.orderId
  103. }
  104. const {data: result} = await uni.$http.get('/education/mp-inner-msg/notify/refund', queryObj)
  105. if (result.success) {
  106. return uni.$showMsg('已通知该学员,请耐心等待')
  107. }
  108. },
  109. // 获取手机号
  110. async getPhone() {
  111. const {data: result} = await uni.$http.get('/ucenter/mini-program-openid-uid/getPhoneByUid', {uid: this.info.studentId})
  112. this.phone = result.data.phone
  113. this.showPhone = true
  114. },
  115. // 获取订单信息
  116. async getOne(id) {
  117. console.log(id)
  118. const queryObj = {
  119. orderId: id
  120. }
  121. const {data: result} = await uni.$http.get('/payment/order-info/getOrderInfoByOrderId', {orderId: id})
  122. this.info = result.data.one
  123. // 判断支付状态
  124. if (this.info.status !== '未支付') {
  125. this.countDown = false
  126. this.pay = true
  127. }
  128. if (this.info.status === '未支付' && this.time == -2){
  129. this.disabled = true
  130. this.info.status = '已超时'
  131. }
  132. if (this.info.status === '支付成功') {
  133. this.observed = true
  134. }
  135. if (this.info.isRefund === 1) {
  136. this.buttonDisabled = true
  137. }
  138. },
  139. // 倒计时
  140. async getCountDown(id) {
  141. const queryObj = {
  142. orderId: id
  143. }
  144. const { data: result } = await uni.$http.get('/payment/order-info/getCountDown',queryObj)
  145. this.time = result.data.time
  146. if (this.time != -2) {
  147. this.minute = this.time / 60
  148. this.second = this.time % 60
  149. }
  150. },
  151. async paymentButton() {
  152. const queryObj = {
  153. inviteId: this.info.inviteId
  154. }
  155. const {data: result} = await uni.$http.get('/payment/wx-pay/jsapi', queryObj)
  156. // 微信官方调起支付
  157. wx.requestPayment({
  158. timeStamp: result.data.timeStamp,
  159. nonceStr: result.data.nonceStr,
  160. package: 'prepay_id=' + result.data.prepay_id,
  161. signType: 'RSA',
  162. paySign: result.data.paySign,
  163. success: res => {
  164. this.timer = setInterval(() => {
  165. this.queryOrderStatus()
  166. }, 1000)
  167. },
  168. fail: res => {
  169. wx.showToast({
  170. title: '支付失败',
  171. icon: 'none',
  172. duration: 2000
  173. })
  174. }
  175. })
  176. },
  177. queryOrderStatus() {
  178. // 验证本地订单状态,并推送消息
  179. uni.request({
  180. url: 'http://192.168.0.214:8222/payment/order-info/queryOrderStatus?orderId=' + this.info.orderId,
  181. success: (res) => {
  182. if (res.data.message === '支付成功') {
  183. clearInterval(this.timer)
  184. wx.showToast({
  185. title: '支付成功',
  186. icon: 'none',
  187. duration: 2000
  188. })
  189. this.info.status = '支付成功'
  190. this.countDown = false
  191. this.pay = true
  192. }
  193. }
  194. });
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss" scoped>
  200. /* 设置全局边距 */
  201. .orderWrapper{
  202. padding-left: 20rpx;
  203. /* background-color: yellowgreen; */
  204. }
  205. /* 头部区域 */
  206. .orderHead{
  207. display: flex;
  208. position: relative;
  209. height: 200rpx;
  210. padding-top: 20rpx;
  211. }
  212. /* 头像 */
  213. .headImg{
  214. width: 160rpx;
  215. height: 160rpx;
  216. border-radius: 30rpx;
  217. position: absolute;
  218. right: 30rpx;
  219. }
  220. .orderHeadTitle{
  221. display: flex;
  222. flex-direction: column;
  223. height: 80px;
  224. justify-content: space-around;
  225. }
  226. /* 设置内容样式 */
  227. .orderDetail,
  228. .courseNum,
  229. .orderPayStatus{
  230. margin-left: 20rpx;
  231. font-weight: bold;
  232. }
  233. .courseNum{
  234. color: #00B0F0;
  235. text-decoration: underline;
  236. }
  237. /* 支付状态字体样式 */
  238. .orderPayStatus{
  239. color: red;
  240. }
  241. /* 中部区域 */
  242. .orderMid{
  243. height: 220rpx;
  244. display: flex;
  245. flex-direction: column;
  246. justify-content: space-around;
  247. }
  248. /* 底部区域 */
  249. .orderBottom{
  250. margin-top: 40rpx;
  251. height: 260rpx;
  252. display: flex;
  253. flex-direction: column;
  254. justify-content: space-around;
  255. }
  256. /* 支付倒计时 */
  257. .orderPay{
  258. margin-top: 40rpx;
  259. display: flex;
  260. align-items: baseline;
  261. }
  262. /* 倒计时时间格式 */
  263. .orderPayTime{
  264. padding-left: 20rpx;
  265. font-weight: bold;
  266. font-size: 40rpx;
  267. color: red;
  268. }
  269. /* 提醒信息 */
  270. .warning{
  271. display: flex;
  272. justify-content: center;
  273. margin-top: 60rpx;
  274. }
  275. /* 提醒信息详情 */
  276. .warningDetail{
  277. width: 80%;
  278. display: flex;
  279. flex-direction: column;
  280. font-size: 44rpx;
  281. font-weight: bold;
  282. color: red;
  283. }
  284. /* 支付及查看信息按钮居中排列 */
  285. .payWrapper{
  286. display: flex;
  287. justify-content: center;
  288. }
  289. .paidSucceed{
  290. display: flex;
  291. width: 100%;
  292. justify-content: space-around;
  293. }
  294. .payButton{
  295. border-radius: 30rpx;
  296. }
  297. .pay{
  298. /* display: flex; */
  299. width: 100%;
  300. }
  301. </style>