orderDetail.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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.originalGold}}</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.originalGold}}</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="error">去支付</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" 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 v-model="password"
  105. @confirm="toPayOrder"
  106. maxlength="30"
  107. style="text-align: center;" type="password"
  108. placeholder="请输入支付密码" />
  109. </view>
  110. <view class="fot-btn">
  111. <u-button @click="toPayOrder" type="error" >确认支付</u-button>
  112. </view>
  113. </view>
  114. </u-popup>
  115. </view>
  116. </template>
  117. <script>
  118. import {
  119. orderDetail,
  120. signPay,
  121. existPayPwd
  122. } from '@/api/order.js'
  123. import {
  124. getLookUpDatas
  125. } from '@/api/data.js'
  126. import moment from 'moment'
  127. export default {
  128. data() {
  129. return {
  130. orderInfo: {},
  131. totalPrice: 0, // 支付合计
  132. password: '', // 支付密码
  133. showSetPswModal: false, // 设置支付密码弹窗
  134. showInputPsw: false, // 打开输入密码弹窗
  135. showLeavePsw: false, // 打开确定放弃弹窗
  136. orderId: '', // 订单id
  137. leftTime: null,
  138. payFinish: false // 是否支付成功
  139. }
  140. },
  141. onLoad(options) {
  142. // 监听设置密码是否成功
  143. uni.$once('setPswSuccess', this.setPsw)
  144. if (options.id) {
  145. console.log(options.id)
  146. this.orderId = options.id
  147. this.getOrderDetail()
  148. }
  149. },
  150. computed: {
  151. },
  152. methods: {
  153. // 支付剩余时间
  154. leftTimeFun() {
  155. const date1 = moment().toArray() // 当前时间 数组形式
  156. const date2 = moment(this.orderInfo.orderTime).toDate() // 下单时间 日期格式
  157. const date3 = moment(date2).toArray() // 下单时间 数组形式
  158. const date4 = moment(date1).diff(moment(date3), 'seconds')//计算相差的秒数
  159. const tt = 30 - Math.ceil(date4/60) //向上取整
  160. if (tt > 0) {
  161. this.leftTime = tt
  162. } else {
  163. // this.getOrderDetail()
  164. this.leftTime = '00'
  165. }
  166. },
  167. // 获取订单详情
  168. getOrderDetail() {
  169. orderDetail({
  170. id: this.orderId
  171. }).then(res => {
  172. console.log(res,'rrrrrrrr')
  173. if (res.status == 200) {
  174. this.orderInfo = res.data
  175. if(this.orderInfo.orderState=='WAIT_PAY') {
  176. this.leftTimeFun()
  177. }
  178. }
  179. })
  180. },
  181. // 跳转到设置支付密码页
  182. toSetPwd () {
  183. uni.navigateTo({
  184. url:"/pages/userCenter/userInfo/smsVerification"
  185. })
  186. },
  187. // 设置密码成功, 打开输入密码弹窗
  188. setPsw (e) {
  189. if (e.success) {
  190. this.showInputPsw = true
  191. }
  192. },
  193. // 关闭输入密码弹窗
  194. closePayModal(){
  195. if(!this.payFinish) {
  196. this.showLeavePsw = true
  197. }
  198. },
  199. //确认放弃
  200. canclePay() {
  201. this.password = ''
  202. this.showLeavePsw = false
  203. this.showInputPsw = false
  204. },
  205. // 继续支付
  206. payAgain () {
  207. this.showLeavePsw = false
  208. this.showInputPsw = true
  209. },
  210. // 支付 判断用户是否设置过支付密码
  211. toPay() {
  212. this.totalPrice = this.orderInfo.originalGold
  213. this.payFinish = false
  214. // 判断用户是否设置过支付密码
  215. existPayPwd().then(res=>{
  216. console.log(res,'rrrrrr')
  217. if(res.status == 200) {
  218. // 设置过支付密码,输入密码
  219. if(res.data) {
  220. this.showInputPsw = true
  221. } else {
  222. // 没设置过支付密码,提示设置密码
  223. this.showSetPswModal = true
  224. }
  225. }
  226. })
  227. },
  228. // 支付
  229. toPayOrder() {
  230. if (this.password === '') {
  231. uni.showToast({
  232. title: '请先输入支付密码',
  233. icon: 'none'
  234. })
  235. return false
  236. }
  237. let id = this.orderInfo.id
  238. let params = {
  239. payPwd: this.password,
  240. id: id
  241. }
  242. signPay(params).then(res=>{
  243. this.btnLoading = false
  244. if(res.status == 200) {
  245. // 关闭弹窗 刷新页面
  246. this.payFinish = true
  247. this.showInputPsw = false
  248. this.getOrderDetail()
  249. // 刷新订单列表
  250. uni.$emit('refresh')
  251. // 跳转到支付完成界面
  252. uni.navigateTo({
  253. url:"/pages/toOrder/payFinish?id=" + id
  254. })
  255. } else{
  256. this.password = ''
  257. }
  258. })
  259. },
  260. },
  261. }
  262. </script>
  263. <style lang="scss">
  264. page {
  265. height: 100%;
  266. background-color: #fff;
  267. }
  268. .order-pages {
  269. width: 100%;
  270. height: 100%;
  271. padding: 0 24upx;
  272. display: flex;
  273. flex-direction: column;
  274. .order-info {
  275. width: 100%;
  276. flex: 1;
  277. overflow-y: scroll;
  278. // 状态
  279. .order-status {
  280. padding: 30upx 0;
  281. text-align: center;
  282. .status-title {
  283. font-size: 36upx;
  284. color: #000;
  285. }
  286. .status-care {
  287. font-size: 24upx;
  288. margin-top: 10upx;
  289. color: #a9aaac;
  290. >text {
  291. color: red;
  292. }
  293. }
  294. }
  295. // 地址
  296. .order-address {
  297. font-size: 32upx;
  298. padding: 20upx 0;
  299. >view {
  300. line-height: 60upx;
  301. }
  302. .address-title {
  303. color: #000;
  304. }
  305. }
  306. // 订单中商品列表
  307. .bundle-list {
  308. display: flex;
  309. padding: 20upx 10upx;
  310. font-size: 28upx;
  311. border-bottom: 1px solid #F8F8F8;
  312. .img-cont {
  313. width: 158rpx;
  314. height: 140upx;
  315. border-radius: 15upx;
  316. overflow: hidden;
  317. >image {
  318. width: 100%;
  319. height: 100%;
  320. }
  321. }
  322. >view {
  323. &:last-child {
  324. flex: 1;
  325. margin-left: 20upx;
  326. padding: 10upx 0;
  327. display: flex;
  328. flex-direction: column;
  329. justify-content: space-between;
  330. }
  331. }
  332. .bundle-num {
  333. display: flex;
  334. justify-content: space-between;
  335. }
  336. }
  337. .price-text {
  338. font-size: 20upx;
  339. margin-left: 10upx;
  340. }
  341. .price-num {
  342. font-size: 32upx;
  343. color: red;
  344. font-weight: 600;
  345. margin-right: 6rpx;
  346. }
  347. .u-cell {
  348. padding: 10rpx 32rpx;
  349. }
  350. }
  351. // 乐豆数量
  352. .num-cont{
  353. display: flex;
  354. align-items: center;
  355. float: right;
  356. }
  357. .footer {
  358. padding: 20rpx;
  359. }
  360. // 支付密码弹窗
  361. .slot-content{
  362. padding: 30upx 0;
  363. display: flex;
  364. flex-direction: column;
  365. align-items: center;
  366. justify-content: space-between;
  367. .text-cont{
  368. width: 100%;
  369. padding: 60upx 0;
  370. display: flex;
  371. align-items: center;
  372. justify-content: center;
  373. .num-big{
  374. font-size: 40upx;
  375. color: red;
  376. font-weight: 600;
  377. margin-right: 6rpx;
  378. }
  379. }
  380. .footer{
  381. width: 80%;
  382. border-bottom: 1px solid #b1b1b1;
  383. margin-bottom: 30upx;
  384. }
  385. }
  386. }
  387. </style>