my_order_detail.vue 8.9 KB

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