orderDetail.vue 9.4 KB

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