storeConsumption.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <script>
  2. import UCodeInput from "../../components/uview-ui/components/u-code-input/u-code-input.vue";
  3. import {
  4. getCustomerInfo, getUserInfo,
  5. } from "../../common/api/user.js";
  6. export default {
  7. name: "storeConsumption",
  8. components: {UCodeInput},
  9. data() {
  10. return {
  11. orderNo: '',
  12. goodsList: [],
  13. pwd:"",
  14. show: false,
  15. userInfo: {},
  16. customerInfo: {},
  17. detailData: {
  18. amount_discount:0,
  19. discount:0,
  20. order_no:"--",
  21. created_at:"--",
  22. amount_goods:0,
  23. number_item:0,
  24. status:1
  25. },
  26. topData: {
  27. top: 0,
  28. height: 0
  29. },
  30. }
  31. },
  32. onLoad(options) {
  33. this.orderNo = options.orderNo
  34. console.log(
  35. 'options',
  36. options
  37. )
  38. // const mData = uni.getStorageSync('selectTaskData') || undefined
  39. },
  40. onShow() {
  41. const topData = uni.getMenuButtonBoundingClientRect()
  42. this.topData.top = topData.top
  43. this.topData.height = topData.height
  44. this.expenseDetail()
  45. this.getUserInfo()
  46. },
  47. methods: {
  48. splitStr(str) {
  49. if (!str) return ""
  50. var split = str.split(';;');
  51. return split[split.length - 1]
  52. },
  53. async getUserInfo() {
  54. const data = {};
  55. await getUserInfo(data)
  56. .then((res) => {
  57. if (res.data) {
  58. this.userInfo = res.data;
  59. }
  60. });
  61. },
  62. toPay() {
  63. this.show = true;
  64. this.pwd = ""; // 清空上次输入的密码
  65. },
  66. expenseDetail() {
  67. getCustomerInfo().then(res => {
  68. this.customerInfo = res.data||{}
  69. if (this.customerInfo){
  70. this.customerInfo.balance_total = this.customerInfo.balance_total ? parseFloat(this.customerInfo.balance_total) : 0;
  71. this.customerInfo.balance_used = this.customerInfo.balance_used ? parseFloat(this.customerInfo.balance_used) : 0;
  72. this.customerInfo.balance_num = this.customerInfo.balance_total - this.customerInfo.balance_used;
  73. }
  74. })
  75. this.$api.expenseDetail(this.orderNo).then(res => {
  76. this.detailData = res.data
  77. this.goodsList = res.data.items || []
  78. })
  79. },
  80. open() {
  81. },
  82. finish(e) {
  83. this.$api.expensePay({order_no:this.orderNo,pay_pswd:e}).then(res => {
  84. uni.showToast({
  85. title: res.msg,
  86. success: (res) => {
  87. this.close()
  88. this.expenseDetail()
  89. uni.hideKeyboard();
  90. },
  91. });
  92. })
  93. },
  94. forgotPwd(){
  95. if (this.userInfo.pay_pswd && this.userInfo.pay_pswd.length > 0 ) {
  96. uni.navigateTo({
  97. url: "/subPages/setting/setPwd?type=set-2",
  98. });
  99. }else{
  100. uni.navigateTo({
  101. url: "/subPages/setting/setPwd?type=add",
  102. });
  103. }
  104. },
  105. close() {
  106. this.show = false
  107. // console.log('close');
  108. }
  109. }
  110. }
  111. </script>
  112. <template>
  113. <view class="common-page">
  114. <view class="header-box" :style="{
  115. paddingBottom: '30rpx',
  116. paddingTop: '60rpx',
  117. }" id="headerBox" ref="headerBox">
  118. <view class="success-con fs16" v-if="detailData.status===0">
  119. <view class="display-flex-content-center">
  120. <u-icon size="50rpx" name="checkmark-circle-fill" color="#E2B98E"></u-icon>
  121. <text class="fw700 ml5 success-title-text">待确认</text>
  122. </view>
  123. <view class="text-center mtr20 mt5">请确认您的店内消费订单信息。</view>
  124. </view>
  125. <view class="success-con fs16" v-else>
  126. <view class="display-flex-content-center">
  127. <u-icon size="50rpx" name="checkmark-circle-fill" color="#E2B98E"></u-icon>
  128. <text class="fw700 ml5 success-title-text">已确认</text>
  129. </view>
  130. <view class="text-center mtr20 mt5">您的店内消费订单已确认。</view>
  131. </view>
  132. </view>
  133. <view class="content-box">
  134. <view class="common-card">
  135. <view class="display-flex-center" style="justify-content: space-between;">
  136. <text class="fs14 fw400 color-666">用户信息:</text>
  137. <view class="display-flex-center">
  138. <text class="fs14 fw400 color-333">{{ userInfo.username }}</text>
  139. <text class="fs14 fw400 color-333 ml15">{{ userInfo.phone }}</text>
  140. </view>
  141. </view>
  142. <view class="display-flex-center mt15" style="justify-content: space-between;">
  143. <text class="fs14 fw400 color-666">订单编号:</text>
  144. <text class="fs14 fw400 color-333">{{ detailData.order_no }}</text>
  145. </view>
  146. <view class="display-flex-center mt15" style="justify-content: space-between;">
  147. <text class="fs14 fw400 color-666">生成时间:</text>
  148. <text class="fs14 fw400 color-333">{{ detailData.created_at }}</text>
  149. </view>
  150. </view>
  151. <!-- 订单编号 -->
  152. <view class="common-card">
  153. <view style="margin: 0 auto;" class="color-333 fw600 fs16 lh20">
  154. 消费信息
  155. </view>
  156. <!-- 已选商品 -->
  157. <view class="display-flex-center" style="margin-top: 30rpx" v-for="(item, index) in goodsList" :key="index">
  158. <image style="width: 155rpx; height: 155rpx; border-radius: 10rpx;margin-right: 10rpx;flex-shrink: 0;"
  159. :src="item.goods_cover" mode="aspectFill">
  160. </image>
  161. <view class="ml10" style=" width: 100%">
  162. <view class="display-flex-center mb10">
  163. <text class=" text-overflow-single goods-name">{{ item.goods_name||"--" }}</text>
  164. </view>
  165. <view class="display-flex-center mb10">
  166. <text class="color-888 flex-shrink fw400 fs12 lh16">规格:</text>
  167. <text class=" text-overflow-single fw400 fs12 lh16">{{ splitStr(item.goods_spec ||"--") }}</text>
  168. </view>
  169. <view class="display-flex-between " style="justify-content: space-between; width: 100%">
  170. <text class="fw400 color-333 fs12 mb8">¥
  171. <text class="fw700 color-333 fs16 mb8">{{ item.price_selling || 0 }}</text>
  172. </text>
  173. <text class="color-888">×{{ item.item_num || 0 }}</text>
  174. </view>
  175. </view>
  176. </view>
  177. <u-divider :dashed="true"></u-divider>
  178. <view class="goods-total display-flex-center">
  179. <view class="fs12 color-333 fw400">
  180. 共{{ detailData.number_item }}件商品&nbsp;&nbsp; 总计:
  181. <text class=" fs12 fw400">¥</text>
  182. <text class="fw700 fs18">{{ detailData.amount_goods }}</text>
  183. </view>
  184. </view>
  185. </view>
  186. <view class="common-card">
  187. <view class="display-flex-center mt15" style="justify-content: space-between;">
  188. <text class="fs14 fw400 color-666">折扣</text>
  189. <text class="fs14 fw400 color-333">{{ detailData.discount }}</text>
  190. </view>
  191. <view class="display-flex-center mt15" style="justify-content: space-between;">
  192. <text class="fs14 fw400 color-666">折扣后</text>
  193. <text class=" fs12 fw400">¥
  194. <text class="fw700 fs18">{{ detailData.amount_discount }}</text>
  195. </text>
  196. </view>
  197. </view>
  198. </view>
  199. <!-- 底部支付区域 -->
  200. <view class="bottom-box " v-if="detailData.status===0" >
  201. <view class="balance display-flex-center" >
  202. <image style="width: 32rpx;height: 32rpx;" :src="require('../static/store-1.png')">
  203. </image>
  204. <text class="balance-text ml10">账户余额:¥{{ customerInfo.balance_num }}</text>
  205. </view>
  206. <view class=" display-flex-center" style="justify-content: space-between; width: calc(100% - 60rpx); padding: 27rpx 30rpx;">
  207. <view>应付:
  208. <text class="color-556 fs12 fw400">¥</text>
  209. <text class="fw700 fs20 color-556">{{ detailData.amount_discount }}</text>
  210. </view>
  211. <view class="settle-center-btn" @click="toPay">确认账单</view>
  212. </view>
  213. </view>
  214. <u-popup :show="show" :round="10" :closeable="true" mode="center" @close="close" @open="open">
  215. <view class="payment-popup">
  216. <view class="payment-popup-title display-flex-content-center mt20">请输入安全密码</view>
  217. <view class=" display-flex-content-center mt20">
  218. <text class=" fs12 fw400">¥
  219. <text class="fw700 fs20">{{ detailData.amount_discount }}</text>
  220. </text>
  221. </view>
  222. <view class=" display-flex-content-center mt30">
  223. <u-code-input ref="codeInputRef" @finish="finish" v-model="pwd" :maxlength="6" mode="box" dot :focus="true"></u-code-input>
  224. </view>
  225. <view class="forgot-password display-flex-content-center mt20" @click="forgotPwd">未设置/忘记密码?</view>
  226. </view>
  227. </u-popup>
  228. </view>
  229. </template>
  230. <style lang="scss" scoped>
  231. .payment-popup {
  232. width: 500rpx;
  233. height: 408rpx;
  234. padding: 0 30rpx;
  235. background: #FFFFFF;
  236. border-radius: 32rpx 32rpx 32rpx 32rpx;
  237. }
  238. .payment-popup-title {
  239. font-weight: 400;
  240. font-size: 32rpx;
  241. color: #333333;
  242. line-height: 40rpx;
  243. text-align: center;
  244. font-style: normal;
  245. text-transform: none;
  246. }
  247. .forgot-password{
  248. font-weight: 400;
  249. font-size: 24rpx;
  250. color: #888888;
  251. line-height: 32rpx;
  252. text-align: justify;
  253. font-style: normal;
  254. text-transform: none;
  255. }
  256. .common-page {
  257. height: 100vh;
  258. overflow-y: auto;
  259. // padding: 20rpx;
  260. color: #2C2C2C;
  261. padding-bottom: 188rpx;
  262. box-sizing: border-box;
  263. }
  264. .coupon-list {
  265. padding: 30rpx 20rpx;
  266. background-color: #fff;
  267. border-radius: 20rpx 20rpx 0 0;
  268. }
  269. .bottom-box {
  270. position: fixed;
  271. bottom: 0;
  272. width: 100%;
  273. height: 242rpx;
  274. padding: 0;
  275. left: 0;
  276. right: 0;
  277. box-sizing: border-box;
  278. background-color: #fff;
  279. z-index: 1000;
  280. border-radius: 24rpx 24rpx 0rpx 0rpx;
  281. }
  282. .balance{
  283. position: relative;
  284. width: 100%;
  285. height: 72rpx;
  286. padding: 0 30rpx;
  287. }
  288. .balance::before {
  289. content: '';
  290. position: absolute;
  291. top: 0;
  292. left: 0;
  293. width: 100%;
  294. height: 100%;
  295. background: linear-gradient(315deg, #CA9359 0%, #E2B98E 100%);
  296. border-radius: 0;
  297. opacity: 0.1;
  298. z-index: -1;
  299. }
  300. .balance-text{
  301. font-weight: 400;
  302. font-size: 28rpx;
  303. color: #C29556;
  304. line-height: 36rpx;
  305. text-align: center;
  306. font-style: normal;
  307. text-transform: none;
  308. }
  309. .settle-center-btn {
  310. height: 76rpx;
  311. line-height: 78rpx;
  312. width: 170rpx;
  313. padding: 0 29rpx;
  314. color: #fff;
  315. background: linear-gradient(315deg, #CA9359 0%, #E2B98E 100%);
  316. border-radius: 292rpx 292rpx 292rpx 292rpx;
  317. font-size: 32rpx;
  318. text-align: center;
  319. margin-left: 30rpx;
  320. }
  321. .goods-name {
  322. font-family: PingFang SC-Bold;
  323. font-weight: 400;
  324. font-size: 28rpx;
  325. color: #333333;
  326. line-height: 40rpx;
  327. text-align: left;
  328. font-style: normal;
  329. text-transform: none;
  330. // 加粗
  331. font-weight: bold;
  332. }
  333. .content-box {
  334. padding: 20rpx;
  335. }
  336. .goods-price {
  337. font-family: D-DIN-Regular;
  338. font-weight: 400;
  339. font-size: 28rpx;
  340. color: #333333;
  341. line-height: 48rpx;
  342. text-align: center;
  343. font-style: normal;
  344. text-transform: none;
  345. }
  346. .navbar-box {
  347. position: relative;
  348. }
  349. .success-title-text {
  350. font-size: 40rpx;
  351. color: #333333;
  352. line-height: 50rpx;
  353. text-align: center;
  354. font-style: normal;
  355. text-transform: none;
  356. // 加粗
  357. font-weight: bold;
  358. }
  359. .text-center {
  360. font-family: PingFang SC, PingFang SC;
  361. font-weight: 400;
  362. font-size: 24rpx;
  363. color: #666666;
  364. line-height: 40rpx;
  365. text-align: center;
  366. font-style: normal;
  367. text-transform: none;
  368. }
  369. .good-card {
  370. padding: 38rpx 22rpx;
  371. color: #7A7A7A;
  372. ::v-deep {
  373. .u-textarea {
  374. background: #F6F6F6;
  375. border-radius: 12rpx 12rpx 12rpx 12rpx;
  376. border: none;
  377. padding: 18rpx;
  378. .u-textarea__count {
  379. background-color: transparent !important;
  380. }
  381. }
  382. }
  383. }
  384. .goods-list {
  385. margin: 0 30rpx;
  386. padding: 30rpx 0;
  387. border-bottom: 1rpx solid #F5F5F5;
  388. }
  389. .goods-total {
  390. justify-content: flex-end;
  391. margin: 27rpx 20rpx;
  392. }
  393. </style>