my_order_detail.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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" @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 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 class="teachPayMent" :disabled="disabled" type="primary" style="border-radius: 40rpx;" @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. toNeedDetail() {
  98. uni.navigateTo({
  99. url: '/subpkg/student/require/student_require_all_detail?requireId=' + encodeURIComponent(this.info.requireId)
  100. })
  101. },
  102. toCourseDetail() {
  103. uni.navigateTo({
  104. url: '/subpkg/teacher/course/teacher_course_all_detail?courseId=' + encodeURIComponent(this.info.courseId)
  105. })
  106. },
  107. // 发送申请退款消息
  108. async applyForRefund() {
  109. this.buttonDisabled = true
  110. const queryObj = {
  111. studentId: this.info.studentId,
  112. orderId: this.info.orderId
  113. }
  114. const {data: result} = await uni.$http.get('/education/mp-inner-msg/notify/refund', queryObj)
  115. uni.$showMsg(result.message)
  116. },
  117. // 获取手机号
  118. async getPhone() {
  119. const {data: result} = await uni.$http.get('/ucenter/mini-program-openid-uid/getPhoneByUid', {uid: this.info.studentId})
  120. this.phone = result.data.phone
  121. this.showPhone = true
  122. },
  123. // 获取订单详情信息
  124. async getOne(id) {
  125. const {data: result} = await uni.$http.get('/payment/order-info/getOrderInfoByOrderId', {orderId: id})
  126. this.info = result.data.one
  127. // 判断支付状态
  128. if (this.info.status !== '未支付') {
  129. this.countDown = false
  130. this.pay = true
  131. }
  132. if (this.info.status === '未支付' && this.time == -2){
  133. this.disabled = true
  134. this.info.status = '已超时'
  135. }
  136. if (this.info.status === '支付成功') {
  137. this.observed = true
  138. }
  139. if (this.info.isRefund === 1) {
  140. this.buttonDisabled = true
  141. }
  142. },
  143. // 倒计时
  144. async getCountDown(id) {
  145. const queryObj = {
  146. orderId: id
  147. }
  148. const { data: result } = await uni.$http.get('/payment/order-info/getCountDown',queryObj)
  149. this.time = result.data.time
  150. if (this.time != -2) {
  151. this.minute = this.time / 60
  152. this.second = this.time % 60
  153. }
  154. },
  155. // 支付
  156. async paymentButton() {
  157. const queryObj = {
  158. inviteId: this.info.inviteId
  159. }
  160. const {data: result} = await uni.$http.get('/payment/wx-pay/jsapi', queryObj)
  161. // 微信官方调起支付
  162. wx.requestPayment({
  163. timeStamp: result.data.timeStamp,
  164. nonceStr: result.data.nonceStr,
  165. package: 'prepay_id=' + result.data.prepay_id,
  166. signType: 'RSA',
  167. paySign: result.data.paySign,
  168. success: res => {
  169. this.timer = setInterval(() => {
  170. this.queryOrderStatus()
  171. }, 1000)
  172. },
  173. fail: res => {
  174. wx.showToast({
  175. title: '支付失败',
  176. icon: 'none',
  177. duration: 2000
  178. })
  179. }
  180. })
  181. },
  182. queryOrderStatus() {
  183. // 验证本地订单状态,并推送消息
  184. uni.request({
  185. url: `${uni.$http.baseUrl}/payment/order-info/queryOrderStatus?orderId=` + this.info.orderId,
  186. success: (res) => {
  187. if (res.data.message === '支付成功') {
  188. clearInterval(this.timer)
  189. wx.showToast({
  190. title: '支付成功',
  191. icon: 'none',
  192. duration: 2000
  193. })
  194. this.info.status = '支付成功'
  195. this.countDown = false
  196. this.pay = true
  197. }
  198. }
  199. });
  200. }
  201. }
  202. }
  203. </script>
  204. <!-- 设置页面背景 -->
  205. <style lang="scss">
  206. page{
  207. height: 100%;
  208. // background-color: #FFF;
  209. }
  210. </style>
  211. <style lang="scss" scoped>
  212. /* 设置全局边距 */
  213. .orderWrapper{
  214. padding-left: 20rpx;
  215. /* background-color: yellowgreen; */
  216. }
  217. /* 头部区域 */
  218. .orderHead{
  219. display: flex;
  220. position: relative;
  221. height: 200rpx;
  222. padding-top: 20rpx;
  223. }
  224. /* 头像 */
  225. .headImg{
  226. width: 160rpx;
  227. height: 160rpx;
  228. border-radius: 30rpx;
  229. position: absolute;
  230. right: 30rpx;
  231. }
  232. .orderHeadTitle{
  233. display: flex;
  234. flex-direction: column;
  235. height: 80px;
  236. justify-content: space-around;
  237. }
  238. /* 设置内容样式 */
  239. .orderDetail,
  240. .courseNum,
  241. .orderPayStatus{
  242. margin-left: 20rpx;
  243. font-weight: bold;
  244. }
  245. .courseNum{
  246. color: #00B0F0;
  247. text-decoration: underline;
  248. }
  249. /* 支付状态字体样式 */
  250. .orderPayStatus{
  251. color: red;
  252. }
  253. /* 中部区域 */
  254. .orderMid{
  255. height: 220rpx;
  256. display: flex;
  257. flex-direction: column;
  258. justify-content: space-around;
  259. }
  260. /* 底部区域 */
  261. .orderBottom{
  262. margin-top: 40rpx;
  263. height: 260rpx;
  264. display: flex;
  265. flex-direction: column;
  266. justify-content: space-around;
  267. }
  268. /* 支付倒计时 */
  269. .orderPay{
  270. margin-top: 40rpx;
  271. display: flex;
  272. align-items: baseline;
  273. }
  274. /* 倒计时时间格式 */
  275. .orderPayTime{
  276. padding-left: 20rpx;
  277. font-weight: bold;
  278. font-size: 40rpx;
  279. color: red;
  280. }
  281. /* 提醒信息 */
  282. .warning{
  283. display: flex;
  284. justify-content: center;
  285. margin-top: 60rpx;
  286. }
  287. /* 提醒信息详情 */
  288. .warningDetail{
  289. width: 80%;
  290. display: flex;
  291. flex-direction: column;
  292. font-size: 44rpx;
  293. font-weight: bold;
  294. color: red;
  295. }
  296. /* 支付及查看信息按钮居中排列 */
  297. .payWrapper{
  298. margin-top: 40rpx;
  299. display: flex;
  300. justify-content: center;
  301. }
  302. .paidSucceed{
  303. display: flex;
  304. width: 100%;
  305. justify-content: space-around;
  306. }
  307. .teachPayMent{
  308. background-color: #35b882;
  309. }
  310. .payButton{
  311. border-radius: 30rpx;
  312. }
  313. .pay{
  314. /* display: flex; */
  315. width: 100%;
  316. }
  317. </style>