普兆健康管家前端代码仓库
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.

355 lines
8.1 KiB

2 months ago
2 months ago
2 months ago
  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. // todo: check include Overseas Product ?
  113. this.$utils.navigateTo('/pages_order/order/userInfo/infoFill')
  114. this.orderData = {
  115. id: '001',
  116. number: 'BH872381728321983929',
  117. createTime: '2025-04-28 08:14',
  118. }
  119. console.log('orderData', this.orderData)
  120. },
  121. onUnload() {
  122. this.$store.commit('setAddressInfo', null)
  123. },
  124. methods: {
  125. jumpToSelectAddress() {
  126. this.$utils.navigateTo('/pages_order/address/addressList')
  127. },
  128. onConfirmAgreement(confirm) {
  129. if (confirm) {
  130. this.checkboxValue = [1]
  131. } else {
  132. this.checkboxValue = []
  133. }
  134. },
  135. onPay() {
  136. if(!this.checkboxValue.length){
  137. return uni.showToast({
  138. title: '请先同意《用户协议》《隐私协议》《消费者告知》',
  139. icon:'none'
  140. })
  141. }
  142. const { id } = this.orderData
  143. const obj = {
  144. title: '营养套餐消费',
  145. orderId: id,
  146. amount: this.totalPrice,
  147. }
  148. this.$refs.payPopup.open(obj)
  149. },
  150. onPaySuccess() {
  151. uni.reLaunch({
  152. url: '/pages/order/orderList/index'
  153. })
  154. },
  155. },
  156. }
  157. </script>
  158. <style scoped lang="scss">
  159. .page__view {
  160. width: 100vw;
  161. min-height: 100vh;
  162. background-color: $uni-bg-color;
  163. position: relative;
  164. /deep/ .nav-bar__view {
  165. position: fixed;
  166. top: 0;
  167. left: 0;
  168. }
  169. }
  170. .main {
  171. padding: calc(var(--status-bar-height) + 144rpx) 32rpx 310rpx 32rpx;
  172. }
  173. .address {
  174. margin-bottom: 40rpx;
  175. justify-content: space-between;
  176. padding: 24rpx 32rpx;
  177. background: #FFFFFF;
  178. border-radius: 24rpx;
  179. }
  180. .card {
  181. & + & {
  182. margin-top: 32rpx;
  183. }
  184. }
  185. .order {
  186. margin-top: 40rpx;
  187. padding: 32rpx;
  188. background: #FAFAFF;
  189. border: 2rpx solid #FFFFFF;
  190. border-radius: 32rpx;
  191. &-header {
  192. font-family: PingFang SC;
  193. font-weight: 500;
  194. font-size: 36rpx;
  195. line-height: 1.4;
  196. color: #252545;
  197. }
  198. .row {
  199. margin-top: 32rpx;
  200. justify-content: space-between;
  201. font-family: PingFang SC;
  202. font-weight: 400;
  203. line-height: 1.4;
  204. &-label {
  205. font-size: 26rpx;
  206. color: #8B8B8B;
  207. }
  208. &-content {
  209. font-size: 28rpx;
  210. color: #393939;
  211. }
  212. }
  213. }
  214. .notice {
  215. margin-top: 40rpx;
  216. font-family: PingFang SC;
  217. font-weight: 400;
  218. &-header {
  219. font-size: 28rpx;
  220. line-height: 1.4;
  221. color: #393939;
  222. }
  223. &-content {
  224. margin-top: 24rpx;
  225. font-size: 24rpx;
  226. line-height: 1.3;
  227. color: #BABABA;
  228. }
  229. }
  230. .bottom {
  231. position: fixed;
  232. left: 0;
  233. bottom: 0;
  234. width: 100vw;
  235. height: 270rpx;
  236. background: #FFFFFF;
  237. box-sizing: border-box;
  238. .agreement {
  239. display: flex;
  240. padding: 16rpx 40rpx;
  241. background: #EFEAFF;
  242. box-sizing: border-box;
  243. /deep/ .uv-checkbox-group {
  244. flex: none;
  245. }
  246. .desc {
  247. flex: 1;
  248. font-family: PingFang SC;
  249. font-size: 24rpx;
  250. font-weight: 400;
  251. line-height: 40rpx;
  252. color: #8B8B8B;
  253. }
  254. .highlight {
  255. color: $uni-color;
  256. }
  257. }
  258. .bar {
  259. padding: 24rpx 40rpx;
  260. box-sizing: border-box;
  261. column-gap: 30rpx;
  262. .col {
  263. flex: 1;
  264. }
  265. .price {
  266. justify-content: flex-start;
  267. &-label {
  268. font-family: PingFang SC;
  269. font-weight: 400;
  270. font-size: 24rpx;
  271. line-height: 1.4;
  272. color: #626262;
  273. }
  274. &-unit {
  275. margin: 0 8rpx;
  276. font-family: PingFang SC;
  277. font-weight: 500;
  278. font-size: 24rpx;
  279. line-height: 1.4;
  280. color: #7451DE;
  281. }
  282. &-value {
  283. font-family: PingFang SC;
  284. font-weight: 500;
  285. font-size: 40rpx;
  286. line-height: 1.4;
  287. color: #7451DE;
  288. }
  289. }
  290. .btn {
  291. width: 100%;
  292. padding: 16rpx 0;
  293. box-sizing: border-box;
  294. font-family: PingFang SC;
  295. font-weight: 500;
  296. font-size: 36rpx;
  297. line-height: 1;
  298. color: #FFFFFF;
  299. background-image: linear-gradient(to right, #4B348F, #845CFA);
  300. border-radius: 41rpx;
  301. }
  302. }
  303. }
  304. </style>