orderDetail.vue 10.0 KB

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