my_order_detail.vue 10 KB

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