普兆健康管家前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

352 lines
8.0 KiB

  1. <template>
  2. <view class="page__view">
  3. <navbar title="确认订单" leftClick @leftClick="$utils.navigateBack" color="#191919" bgColor="#F3F2F7" />
  4. <view class="main">
  5. <view class="flex address" @click="jumpToSelectAddress">
  6. <addressView :data="addressData" :showIcon="true"></addressView>
  7. <uv-icon name="arrow-right" color="#C6C6C6" size="32rpx"></uv-icon>
  8. </view>
  9. <view class="card" v-for="item in payOrderProduct" :key="item.id">
  10. <productCard :data="item"></productCard>
  11. </view>
  12. <view class="order" v-if="orderData">
  13. <view class="order-header">
  14. 订单信息
  15. </view>
  16. <view class="flex row">
  17. <view class="row-label">订单编号</view>
  18. <view class="row-content">{{ orderData.number }}</view>
  19. </view>
  20. <view class="flex row">
  21. <view class="row-label">下单时间</view>
  22. <view class="row-content">{{ $dayjs(orderData.createTime).format('YYYY-MM-DD HH:mm') }}</view>
  23. </view>
  24. </view>
  25. <view class="notice">
  26. <view class="notice-header">下单须知</view>
  27. <view class="notice-content">
  28. <!-- todo: 替换配置项key -->
  29. <uv-parse :content="configList['config_agreement']"></uv-parse>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="bottom">
  34. <view class="agreement">
  35. <uv-checkbox-group
  36. v-model="checkboxValue"
  37. shape="circle"
  38. >
  39. <uv-checkbox
  40. size="40rpx"
  41. icon-size="40rpx"
  42. activeColor="#7451DE"
  43. :name="1"
  44. ></uv-checkbox>
  45. </uv-checkbox-group>
  46. <view class="desc">
  47. 我已阅读并同意
  48. <!-- todo: 替换配置项key -->
  49. <text class="highlight" @click="$refs.modal.open('config_agreement', '用户协议')">用户协议</text>
  50. <!-- todo: 替换配置项key -->
  51. <text class="highlight" @click="$refs.modal.open('config_privacy', '隐私协议')">隐私协议</text>
  52. <!-- todo: 替换配置项key -->
  53. <text class="highlight" @click="$refs.modal.open('config_privacy', '消费者告知')">消费者告知</text>
  54. </view>
  55. </view>
  56. <view class="flex bar">
  57. <view class="flex col price">
  58. <view class="price-label">合计</view>
  59. <view class="price-unit">¥</view><view class="price-value">{{ totalPrice }}</view>
  60. </view>
  61. <button class="col btn" @click="onPay">立即支付</button>
  62. </view>
  63. </view>
  64. <agreementModal ref="modal" @confirm="onConfirmAgreement"></agreementModal>
  65. <payPopup ref="payPopup" @submitted="onPaySuccess"></payPopup>
  66. </view>
  67. </template>
  68. <script>
  69. import { mapState } from 'vuex'
  70. import addressView from '@/pages_order/address/addressView.vue'
  71. import productCard from './productCard.vue'
  72. import agreementModal from '@/pages_order/components/agreementModal.vue'
  73. import payPopup from '@/pages_order/order/payPopup.vue'
  74. export default {
  75. components: {
  76. addressView,
  77. productCard,
  78. agreementModal,
  79. payPopup,
  80. },
  81. data() {
  82. return {
  83. addressData: null,
  84. orderData: null,
  85. checkboxValue : []
  86. }
  87. },
  88. computed: {
  89. ...mapState(['configList', 'userInfo', 'payOrderProduct', 'addressInfo']),
  90. totalPrice() {
  91. return this.payOrderProduct.reduce((price, item) => {
  92. // return price + item.price * (item.count || 1)
  93. return price + item.price
  94. }, 0)
  95. },
  96. },
  97. onShow() {
  98. console.log('onShow')
  99. console.log('address', this.addressInfo)
  100. this.addressData = this.addressInfo || {
  101. id: '001',
  102. name: '郑文锦',
  103. phone: '18108341643',
  104. area: ['海南省', '海口市', '秀英区'],
  105. address: '秀英街道5单元183室',
  106. default: true,
  107. }
  108. },
  109. onLoad() {
  110. console.log('onLoad')
  111. console.log('payOrderProduct', this.payOrderProduct)
  112. this.orderData = {
  113. id: '001',
  114. number: 'BH872381728321983929',
  115. createTime: '2025-04-28 08:14',
  116. }
  117. console.log('orderData', this.orderData)
  118. },
  119. onUnload() {
  120. this.$store.commit('setAddressInfo', null)
  121. },
  122. methods: {
  123. jumpToSelectAddress() {
  124. this.$utils.navigateTo('/pages_order/address/addressList')
  125. },
  126. onConfirmAgreement(confirm) {
  127. if (confirm) {
  128. this.checkboxValue = [1]
  129. } else {
  130. this.checkboxValue = []
  131. }
  132. },
  133. onPay() {
  134. if(!this.checkboxValue.length){
  135. return uni.showToast({
  136. title: '请先同意《用户协议》《隐私协议》《消费者告知》',
  137. icon:'none'
  138. })
  139. }
  140. const { id } = this.orderData
  141. const obj = {
  142. title: '营养套餐消费',
  143. orderId: id,
  144. amount: this.totalPrice,
  145. }
  146. this.$refs.payPopup.open(obj)
  147. },
  148. onPaySuccess() {
  149. uni.reLaunch({
  150. url: '/pages/order/orderList/index'
  151. })
  152. },
  153. },
  154. }
  155. </script>
  156. <style scoped lang="scss">
  157. .page__view {
  158. width: 100vw;
  159. min-height: 100vh;
  160. background-color: $uni-bg-color;
  161. position: relative;
  162. /deep/ .nav-bar__view {
  163. position: fixed;
  164. top: 0;
  165. left: 0;
  166. }
  167. }
  168. .main {
  169. padding: calc(var(--status-bar-height) + 144rpx) 32rpx 310rpx 32rpx;
  170. }
  171. .address {
  172. margin-bottom: 40rpx;
  173. justify-content: space-between;
  174. padding: 24rpx 32rpx;
  175. background: #FFFFFF;
  176. border-radius: 24rpx;
  177. }
  178. .card {
  179. & + & {
  180. margin-top: 32rpx;
  181. }
  182. }
  183. .order {
  184. margin-top: 40rpx;
  185. padding: 32rpx;
  186. background: #FAFAFF;
  187. border: 2rpx solid #FFFFFF;
  188. border-radius: 32rpx;
  189. &-header {
  190. font-family: PingFang SC;
  191. font-weight: 500;
  192. font-size: 36rpx;
  193. line-height: 1.4;
  194. color: #252545;
  195. }
  196. .row {
  197. margin-top: 32rpx;
  198. justify-content: space-between;
  199. font-family: PingFang SC;
  200. font-weight: 400;
  201. line-height: 1.4;
  202. &-label {
  203. font-size: 26rpx;
  204. color: #8B8B8B;
  205. }
  206. &-content {
  207. font-size: 28rpx;
  208. color: #393939;
  209. }
  210. }
  211. }
  212. .notice {
  213. margin-top: 40rpx;
  214. font-family: PingFang SC;
  215. font-weight: 400;
  216. &-header {
  217. font-size: 28rpx;
  218. line-height: 1.4;
  219. color: #393939;
  220. }
  221. &-content {
  222. margin-top: 24rpx;
  223. font-size: 24rpx;
  224. line-height: 1.3;
  225. color: #BABABA;
  226. }
  227. }
  228. .bottom {
  229. position: fixed;
  230. left: 0;
  231. bottom: 0;
  232. width: 100vw;
  233. height: 270rpx;
  234. background: #FFFFFF;
  235. box-sizing: border-box;
  236. .agreement {
  237. display: flex;
  238. padding: 16rpx 40rpx;
  239. background: #EFEAFF;
  240. box-sizing: border-box;
  241. /deep/ .uv-checkbox-group {
  242. flex: none;
  243. }
  244. .desc {
  245. flex: 1;
  246. font-family: PingFang SC;
  247. font-size: 24rpx;
  248. font-weight: 400;
  249. line-height: 40rpx;
  250. color: #8B8B8B;
  251. }
  252. .highlight {
  253. color: $uni-color;
  254. }
  255. }
  256. .bar {
  257. padding: 24rpx 40rpx;
  258. box-sizing: border-box;
  259. column-gap: 30rpx;
  260. .col {
  261. flex: 1;
  262. }
  263. .price {
  264. justify-content: flex-start;
  265. &-label {
  266. font-family: PingFang SC;
  267. font-weight: 400;
  268. font-size: 24rpx;
  269. line-height: 1.4;
  270. color: #626262;
  271. }
  272. &-unit {
  273. margin: 0 8rpx;
  274. font-family: PingFang SC;
  275. font-weight: 500;
  276. font-size: 24rpx;
  277. line-height: 1.4;
  278. color: #7451DE;
  279. }
  280. &-value {
  281. font-family: PingFang SC;
  282. font-weight: 500;
  283. font-size: 40rpx;
  284. line-height: 1.4;
  285. color: #7451DE;
  286. }
  287. }
  288. .btn {
  289. width: 100%;
  290. padding: 16rpx 0;
  291. box-sizing: border-box;
  292. font-family: PingFang SC;
  293. font-weight: 500;
  294. font-size: 36rpx;
  295. line-height: 1;
  296. color: #FFFFFF;
  297. background-image: linear-gradient(to right, #4B348F, #845CFA);
  298. border-radius: 41rpx;
  299. }
  300. }
  301. }
  302. </style>