orderDetail.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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><text class="price-num">{{item.payGold}}</text> <text class="price-text">乐豆</text></view>
  35. <view>X {{item.buyQty}}</view>
  36. </view>
  37. </view>
  38. </view>
  39. <u-gap height="10" bg-color="#f8f8f8"></u-gap>
  40. <!-- 订单信息 -->
  41. <u-cell-group>
  42. <u-cell-item title="订单编号" :value-style="{color: '#000',fontSize: '28upx'}" :arrow="false">
  43. {{orderInfo.orderSn}}
  44. </u-cell-item>
  45. <u-cell-item title="下单时间" :value-style="{color: '#000',fontSize: '28upx'}" :arrow="false">
  46. {{orderInfo.orderTime}}
  47. </u-cell-item>
  48. <u-cell-item v-if="orderInfo.payTime" title="支付时间" :value-style="{color: '#000',fontSize: '28upx'}" :arrow="false">
  49. {{orderInfo.payTime}}
  50. </u-cell-item>
  51. <u-gap height="10" bg-color="#f8f8f8"></u-gap>
  52. <u-cell-item title="商品合计" :value-style="{color: '#000',fontSize: '28upx'}" :arrow="false">
  53. <text class="price-num">{{orderInfo.originalGold}}</text> <text class="price-text">乐豆</text>
  54. </u-cell-item>
  55. <u-cell-item title="运费" :value-style="{color: '#000',fontSize: '28upx'}" :arrow="false">
  56. 免运费
  57. </u-cell-item>
  58. <u-cell-item :title="(orderInfo.orderState=='WAIT_PAY'||orderInfo.orderState=='CANCEL') ? '待支付':'实际支付'" :value-style="{color: '#000',fontSize: '28upx'}"
  59. :arrow="false">
  60. <text class="price-num">{{orderInfo.originalGold}}</text> <text class="price-text">乐豆</text>
  61. </u-cell-item>
  62. </u-cell-group>
  63. </view>
  64. <view v-if="orderInfo.orderState=='WAIT_PAY'" class="footer">
  65. <u-button @click="toPay" type="error">去支付</u-button>
  66. </view>
  67. <!-- 提示用户设置支付密码 -->
  68. <u-modal v-model="showSetPswModal"
  69. content="请先设置支付密码,才能使用乐豆"
  70. show-cancel-button
  71. confirm-text="去设置"
  72. cancel-text="暂时放弃"
  73. @confirm="toSetPwd"
  74. @cancel="showSetPswModal=false"
  75. ></u-modal>
  76. <!-- 确认取消弹窗 -->
  77. <u-modal v-model="showLeavePsw"
  78. title="确认放弃支付吗?"
  79. content="您的订单在30分钟内未支付将被取消"
  80. show-cancel-button
  81. confirm-text="确认放弃"
  82. cancel-text="继续支付"
  83. @confirm="canclePay"
  84. @cancel="payAgain"
  85. ></u-modal>
  86. <!-- 确认支付弹窗 -->
  87. <u-popup mode="center" closeable @close="showLeavePsw=true" v-model="showInputPsw" width="500rpx" >
  88. <view class="slot-content">
  89. <view>确认支付</view>
  90. <view class="text-cont">
  91. <text class="num-big">{{totalPrice}}</text>乐豆
  92. </view>
  93. <view class="footer">
  94. <input v-model="password"
  95. @confirm="toPayOrder"
  96. maxlength="30"
  97. style="text-align: center;" type="password"
  98. placeholder="请输入支付密码" />
  99. </view>
  100. <view class="fot-btn">
  101. <u-button @click="toPayOrder" type="error" >确认支付</u-button>
  102. </view>
  103. </view>
  104. </u-popup>
  105. </view>
  106. </template>
  107. <script>
  108. import {
  109. orderDetail,
  110. signPay,
  111. existPayPwd
  112. } from '@/api/order.js'
  113. import {
  114. getLookUpDatas
  115. } from '@/api/data.js'
  116. export default {
  117. data() {
  118. return {
  119. orderInfo: {},
  120. totalPrice: 0, // 支付合计
  121. password: '', // 支付密码
  122. showSetPswModal: false, // 设置支付密码弹窗
  123. showInputPsw: false, // 打开输入密码弹窗
  124. showLeavePsw: false, // 打开确定放弃弹窗
  125. orderId: '', // 订单id
  126. leftTime: null
  127. }
  128. },
  129. onLoad(options) {
  130. // 监听设置密码是否成功
  131. uni.$once('setPswSuccess', this.setPsw)
  132. if (options.id) {
  133. console.log(options.id)
  134. this.orderId = options.id
  135. this.getOrderDetail()
  136. }
  137. },
  138. computed: {
  139. },
  140. methods: {
  141. // 支付剩余时间
  142. leftTimeFun() {
  143. let nowT = new Date().valueOf() // 现在时间戳
  144. let orderT = new Date(this.orderInfo.orderTime).valueOf() // 下单时间戳
  145. let tt = (1800 * 1000) - (nowT - orderT) // 距离30分钟支付 相差时间戳
  146. console.log(tt,'tttttt')
  147. if (tt >0) {
  148. this.leftTime = parseInt(tt/(60*1000))
  149. } else {
  150. // this.getOrderDetail()
  151. this.leftTime = '00'
  152. }
  153. },
  154. // 获取订单详情
  155. getOrderDetail() {
  156. orderDetail({
  157. id: this.orderId
  158. }).then(res => {
  159. console.log(res,'rrrrrrrr')
  160. if (res.status == 200) {
  161. this.orderInfo = res.data
  162. if(this.orderInfo.orderState=='WAIT_PAY') {
  163. this.leftTimeFun()
  164. }
  165. } else {
  166. uni.showToast({
  167. title: res.message,
  168. icon: 'none'
  169. })
  170. }
  171. })
  172. },
  173. // 跳转到设置支付密码页
  174. toSetPwd () {
  175. uni.navigateTo({
  176. url:"/pages/userCenter/userInfo/smsVerification"
  177. })
  178. },
  179. // 设置密码成功, 打开输入密码弹窗
  180. setPsw (e) {
  181. if (e.success) {
  182. this.showInputPsw = true
  183. }
  184. },
  185. //确认放弃
  186. canclePay() {
  187. this.password = ''
  188. this.showLeavePsw = false
  189. this.showInputPsw = false
  190. },
  191. // 继续支付
  192. payAgain () {
  193. this.showLeavePsw = false
  194. this.showInputPsw = true
  195. },
  196. // 支付 判断用户是否设置过支付密码
  197. toPay() {
  198. this.totalPrice = this.orderInfo.originalGold
  199. // 判断用户是否设置过支付密码
  200. existPayPwd().then(res=>{
  201. console.log(res,'rrrrrr')
  202. if(res.status == 200) {
  203. // 设置过支付密码,输入密码
  204. if(res.data) {
  205. this.showInputPsw = true
  206. } else {
  207. // 没设置过支付密码,提示设置密码
  208. this.showSetPswModal = true
  209. }
  210. } else {
  211. uni.showToast({
  212. title: res.message,
  213. icon: 'none'
  214. })
  215. }
  216. })
  217. },
  218. // 支付
  219. toPayOrder() {
  220. if (this.password === '') {
  221. uni.showToast({
  222. title: '请先输入支付密码',
  223. icon: 'none'
  224. })
  225. return false
  226. }
  227. let id = this.orderInfo.id
  228. let params = {
  229. payPwd: this.password,
  230. id: id
  231. }
  232. signPay(params).then(res=>{
  233. this.btnLoading = false
  234. if(res.status == 200) {
  235. uni.$emit('refresh')
  236. // 跳转到支付完成界面
  237. uni.navigateTo({
  238. url:"/pages/toOrder/payFinish?id=" + id
  239. })
  240. } else{
  241. this.password = ''
  242. uni.showToast({
  243. title: res.message,
  244. icon: 'none'
  245. })
  246. }
  247. })
  248. },
  249. },
  250. }
  251. </script>
  252. <style lang="scss">
  253. page {
  254. height: 100%;
  255. background-color: #fff;
  256. }
  257. .order-pages {
  258. width: 100%;
  259. height: 100%;
  260. padding: 0 24upx;
  261. display: flex;
  262. flex-direction: column;
  263. .order-info {
  264. width: 100%;
  265. flex: 1;
  266. overflow-y: scroll;
  267. // 状态
  268. .order-status {
  269. padding: 30upx 0;
  270. text-align: center;
  271. .status-title {
  272. font-size: 36upx;
  273. color: #000;
  274. }
  275. .status-care {
  276. font-size: 24upx;
  277. margin-top: 10upx;
  278. color: #a9aaac;
  279. >text {
  280. color: red;
  281. }
  282. }
  283. }
  284. // 地址
  285. .order-address {
  286. font-size: 32upx;
  287. padding: 20upx 0;
  288. >view {
  289. line-height: 60upx;
  290. }
  291. .address-title {
  292. color: #000;
  293. }
  294. }
  295. // 订单中商品列表
  296. .bundle-list {
  297. display: flex;
  298. padding: 20upx 10upx;
  299. font-size: 28upx;
  300. border-bottom: 1px solid #F8F8F8;
  301. .img-cont {
  302. width: 158rpx;
  303. height: 140upx;
  304. border-radius: 15upx;
  305. overflow: hidden;
  306. >image {
  307. width: 100%;
  308. height: 100%;
  309. }
  310. }
  311. >view {
  312. &:last-child {
  313. flex: 1;
  314. margin-left: 20upx;
  315. padding: 10upx 0;
  316. display: flex;
  317. flex-direction: column;
  318. justify-content: space-between;
  319. }
  320. }
  321. .bundle-num {
  322. display: flex;
  323. justify-content: space-between;
  324. }
  325. }
  326. .price-text {
  327. font-size: 20upx;
  328. margin-left: 10upx;
  329. }
  330. .price-num {
  331. font-size: 32upx;
  332. color: red;
  333. }
  334. .u-cell {
  335. padding: 10rpx 32rpx;
  336. }
  337. }
  338. .footer {
  339. padding: 20rpx;
  340. }
  341. // 支付密码弹窗
  342. .slot-content{
  343. padding: 30upx 0;
  344. display: flex;
  345. flex-direction: column;
  346. align-items: center;
  347. justify-content: space-between;
  348. .text-cont{
  349. width: 100%;
  350. padding: 60upx 0;
  351. text-align: center;
  352. .num-big{
  353. font-size: 40upx;
  354. color: red;
  355. }
  356. }
  357. .footer{
  358. width: 80%;
  359. border-bottom: 1px solid #b1b1b1;
  360. margin-bottom: 30upx;
  361. }
  362. }
  363. }
  364. </style>