storeConsumption.vue 11 KB

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