orderDetail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <view class="order-pages">
  3. <view class="order-info">
  4. <!-- 订单状态 -->
  5. <view class="order-status">
  6. <view class="status-title">{{orderInfo.orderStateDictValue}}</view>
  7. <view v-if="orderInfo.orderState=='WAIT_PAY'" class="status-care">
  8. 请在 <text>{{leftTime}}</text>分钟内付款,过期系统将自动取消订单
  9. </view>
  10. <view v-if="orderInfo.orderState=='CANCEL'" class="status-care">
  11. 超时未支付,系统已自动取消订单
  12. </view>
  13. </view>
  14. <u-gap height="10" bg-color="#f8f8f8"></u-gap>
  15. <!-- 地址 -->
  16. <view class="order-address">
  17. <view>
  18. <text class="address-title">{{orderInfo.receiveAddress}}</text>
  19. </view>
  20. <view>
  21. <text style="margin-right: 30upx;">{{orderInfo.receiverName}}</text>
  22. <text>{{orderInfo.receiverPhone}}</text>
  23. </view>
  24. </view>
  25. <u-gap height="10" bg-color="#f8f8f8"></u-gap>
  26. <!-- 商品列表 -->
  27. <view class="bundle-list" v-for="item in orderInfo.orderGoodsList" :key="item.id">
  28. <view class="img-cont">
  29. <image :src="item.goodsImages"></image>
  30. </view>
  31. <view>
  32. <view class="ellipsis-two">{{item.goodsName}}</view>
  33. <view class="bundle-num">
  34. <view class="num-cont">
  35. <text class="price-num">{{item.payGold}}</text>
  36. <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
  37. </view>
  38. <view>X {{item.buyQty}}</view>
  39. </view>
  40. </view>
  41. </view>
  42. <u-gap height="10" bg-color="#f8f8f8"></u-gap>
  43. <!-- 订单信息 -->
  44. <u-cell-group>
  45. <u-cell-item title="订单编号" :value-style="{color: '#000'}" :arrow="false">
  46. {{orderInfo.orderSn}}
  47. </u-cell-item>
  48. <u-cell-item title="下单时间" :value-style="{color: '#000'}" :arrow="false">
  49. {{orderInfo.orderTime}}
  50. </u-cell-item>
  51. <u-cell-item v-if="orderInfo.payTime" title="支付时间" :value-style="{color: '#000'}" :arrow="false">
  52. {{orderInfo.payTime}}
  53. </u-cell-item>
  54. <u-gap height="10" bg-color="#f8f8f8"></u-gap>
  55. <u-cell-item title="商品合计" :value-style="{color: '#000'}" :arrow="false">
  56. <view class="num-cont">
  57. <text class="price-num">{{orderInfo.payGold}}</text>
  58. <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
  59. </view>
  60. </u-cell-item>
  61. <u-cell-item title="运费" :value-style="{color: '#000'}" :arrow="false">
  62. 免运费
  63. </u-cell-item>
  64. <u-cell-item :title="(orderInfo.orderState=='WAIT_PAY'||orderInfo.orderState=='CANCEL') ? '待支付':'实际支付'" :value-style="{color: '#000'}"
  65. :arrow="false">
  66. <view class="num-cont">
  67. <text class="price-num">{{orderInfo.payGold}}</text>
  68. <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
  69. </view>
  70. </u-cell-item>
  71. </u-cell-group>
  72. </view>
  73. <view v-if="orderInfo.orderState=='WAIT_PAY'" class="footer">
  74. <u-button @click="toPay" type="success">去支付</u-button>
  75. </view>
  76. <!-- 提示用户设置支付密码 -->
  77. <u-modal v-model="showSetPswModal"
  78. content="请先设置支付密码,才能使用乐豆"
  79. show-cancel-button
  80. confirm-text="去设置"
  81. cancel-text="暂时放弃"
  82. @confirm="toSetPwd"
  83. @cancel="showSetPswModal=false"
  84. ></u-modal>
  85. <!-- 确认取消弹窗 -->
  86. <u-modal v-model="showLeavePsw"
  87. title="确认放弃支付吗?"
  88. content="您的订单在30分钟内未支付将被取消"
  89. show-cancel-button
  90. confirm-text="确认放弃"
  91. cancel-text="继续支付"
  92. @confirm="canclePay"
  93. @cancel="payAgain"
  94. ></u-modal>
  95. <!-- 确认支付弹窗 -->
  96. <u-popup mode="center" :mask-close-able="false" negative-top="300" closeable @close="closePayModal" v-model="showInputPsw" width="500rpx" >
  97. <view class="slot-content">
  98. <view>确认支付</view>
  99. <view class="text-cont">
  100. <text class="num-big">{{totalPrice}}</text>
  101. <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
  102. </view>
  103. <view class="footer">
  104. <input
  105. v-model="password"
  106. :focus="focus"
  107. @confirm="toPayOrder"
  108. maxlength="30"
  109. style="text-align: center;" type="password"
  110. placeholder="请输入支付密码" />
  111. </view>
  112. <view class="fot-btn">
  113. <u-button @click="toPayOrder" type="success" >确认支付</u-button>
  114. </view>
  115. </view>
  116. </u-popup>
  117. </view>
  118. </template>
  119. <script>
  120. import {
  121. orderDetail,
  122. signPay,
  123. existPayPwd
  124. } from '@/api/order.js'
  125. import {
  126. getLookUpDatas
  127. } from '@/api/data.js'
  128. import moment from 'moment'
  129. export default {
  130. data() {
  131. return {
  132. orderInfo: {},
  133. totalPrice: 0, // 支付合计
  134. password: '', // 支付密码
  135. showSetPswModal: false, // 设置支付密码弹窗
  136. showInputPsw: false, // 打开输入密码弹窗
  137. showLeavePsw: false, // 打开确定放弃弹窗
  138. orderId: '', // 订单id
  139. leftTime: null,
  140. payFinish: false , // 是否支付成功
  141. focus: false
  142. }
  143. },
  144. onLoad(options) {
  145. // 监听设置密码是否成功
  146. uni.$once('setPswSuccess', this.setPsw)
  147. if (options.id) {
  148. console.log(options.id)
  149. this.orderId = options.id
  150. this.getOrderDetail()
  151. }
  152. // 开启分享
  153. uni.showShareMenu({
  154. withShareTicket: true,
  155. menus: ['shareAppMessage', 'shareTimeline']
  156. })
  157. },
  158. computed: {
  159. },
  160. methods: {
  161. // 支付剩余时间
  162. leftTimeFun() {
  163. const date1 = moment().toArray() // 当前时间 数组形式
  164. const date2 = moment(this.orderInfo.orderTime).toDate() // 下单时间 日期格式
  165. const date3 = moment(date2).toArray() // 下单时间 数组形式
  166. const date4 = moment(date1).diff(moment(date3), 'seconds')//计算相差的秒数
  167. const tt = 30 - Math.ceil(date4/60) //向上取整
  168. if (tt > 0) {
  169. this.leftTime = tt
  170. } else {
  171. // this.getOrderDetail()
  172. this.leftTime = '00'
  173. }
  174. },
  175. // 获取订单详情
  176. getOrderDetail() {
  177. orderDetail({
  178. id: this.orderId
  179. }).then(res => {
  180. console.log(res,'rrrrrrrr')
  181. if (res.status == 200) {
  182. this.orderInfo = res.data
  183. if(this.orderInfo.orderState=='WAIT_PAY') {
  184. this.leftTimeFun()
  185. }
  186. }
  187. })
  188. },
  189. // 跳转到设置支付密码页
  190. toSetPwd () {
  191. uni.navigateTo({
  192. url:"/pages/userCenter/userInfo/smsVerification"
  193. })
  194. },
  195. // 设置密码成功, 打开输入密码弹窗
  196. setPsw (e) {
  197. if (e.success) {
  198. this.showInputPsw = true
  199. setTimeout(()=>{
  200. this.focus = true
  201. },300)
  202. }
  203. },
  204. // 关闭输入密码弹窗
  205. closePayModal(){
  206. if(!this.payFinish) {
  207. this.showLeavePsw = true
  208. }
  209. },
  210. //确认放弃
  211. canclePay() {
  212. this.password = ''
  213. this.showLeavePsw = false
  214. this.showInputPsw = false
  215. this.focus = false
  216. },
  217. // 继续支付
  218. payAgain () {
  219. this.focus = false
  220. this.showLeavePsw = false
  221. this.showInputPsw = true
  222. setTimeout(()=>{
  223. this.focus = true
  224. },300)
  225. },
  226. // 支付 判断用户是否设置过支付密码
  227. toPay() {
  228. this.totalPrice = this.orderInfo.originalGold
  229. this.payFinish = false
  230. // 判断用户是否设置过支付密码
  231. existPayPwd().then(res=>{
  232. console.log(res,'rrrrrr')
  233. if(res.status == 200) {
  234. // 设置过支付密码,输入密码
  235. if(res.data) {
  236. this.showInputPsw = true
  237. setTimeout(()=>{
  238. this.focus = true
  239. },300)
  240. } else {
  241. // 没设置过支付密码,提示设置密码
  242. this.showSetPswModal = true
  243. }
  244. }
  245. })
  246. },
  247. // 支付
  248. toPayOrder() {
  249. if (this.password === '') {
  250. uni.showToast({
  251. title: '请先输入支付密码',
  252. icon: 'none'
  253. })
  254. return false
  255. }
  256. let id = this.orderInfo.id
  257. let params = {
  258. payPwd: this.password,
  259. id: id
  260. }
  261. signPay(params).then(res=>{
  262. this.btnLoading = false
  263. if(res.status == 200) {
  264. // 关闭弹窗 刷新页面
  265. this.payFinish = true
  266. this.showInputPsw = false
  267. this.getOrderDetail()
  268. // 刷新订单列表
  269. uni.$emit('refresh')
  270. // 跳转到支付完成界面
  271. uni.navigateTo({
  272. url:"/pagesA/toOrder/payFinish?id=" + id
  273. })
  274. } else{
  275. this.password = ''
  276. }
  277. })
  278. },
  279. },
  280. }
  281. </script>
  282. <style lang="scss">
  283. page {
  284. height: 100%;
  285. background-color: #fff;
  286. }
  287. .order-pages {
  288. width: 100%;
  289. height: 100%;
  290. padding: 0 24upx;
  291. display: flex;
  292. flex-direction: column;
  293. .order-info {
  294. width: 100%;
  295. flex: 1;
  296. overflow-y: scroll;
  297. // 状态
  298. .order-status {
  299. padding: 30upx 0;
  300. text-align: center;
  301. .status-title {
  302. font-size: 36upx;
  303. color: #000;
  304. }
  305. .status-care {
  306. font-size: 24upx;
  307. margin-top: 10upx;
  308. color: #a9aaac;
  309. >text {
  310. color: red;
  311. }
  312. }
  313. }
  314. // 地址
  315. .order-address {
  316. font-size: 32upx;
  317. padding: 20upx 0;
  318. >view {
  319. line-height: 40upx;
  320. }
  321. .address-title {
  322. color: #000;
  323. word-break: break-all;
  324. }
  325. }
  326. // 订单中商品列表
  327. .bundle-list {
  328. display: flex;
  329. padding: 20upx 10upx;
  330. font-size: 28upx;
  331. border-bottom: 1px solid #F8F8F8;
  332. .img-cont {
  333. width: 158rpx;
  334. height: 140upx;
  335. border-radius: 15upx;
  336. overflow: hidden;
  337. >image {
  338. width: 100%;
  339. height: 100%;
  340. }
  341. }
  342. >view {
  343. &:last-child {
  344. flex: 1;
  345. margin-left: 20upx;
  346. padding: 10upx 0;
  347. display: flex;
  348. flex-direction: column;
  349. justify-content: space-between;
  350. }
  351. }
  352. .bundle-num {
  353. display: flex;
  354. justify-content: space-between;
  355. }
  356. }
  357. .price-text {
  358. font-size: 20upx;
  359. margin-left: 10upx;
  360. }
  361. .price-num {
  362. font-size: 32upx;
  363. color: red;
  364. font-weight: 600;
  365. margin-right: 6rpx;
  366. }
  367. .u-cell {
  368. padding: 10rpx 32rpx;
  369. }
  370. }
  371. // 乐豆数量
  372. .num-cont{
  373. display: flex;
  374. align-items: center;
  375. float: right;
  376. }
  377. .footer {
  378. padding: 20rpx;
  379. }
  380. // 支付密码弹窗
  381. .slot-content{
  382. padding: 30upx 0;
  383. display: flex;
  384. flex-direction: column;
  385. align-items: center;
  386. justify-content: space-between;
  387. .text-cont{
  388. width: 100%;
  389. padding: 60upx 0;
  390. display: flex;
  391. align-items: center;
  392. justify-content: center;
  393. .num-big{
  394. font-size: 40upx;
  395. color: red;
  396. font-weight: 600;
  397. margin-right: 6rpx;
  398. }
  399. }
  400. .footer{
  401. width: 80%;
  402. border-bottom: 1px solid #b1b1b1;
  403. margin-bottom: 30upx;
  404. }
  405. }
  406. }
  407. </style>