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

307 lines
6.9 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. <template>
  2. <view>
  3. <uv-popup ref="popup" mode="bottom" bgColor="none" >
  4. <view class="popup__view">
  5. <view class="flex header">
  6. <view class="title">支付订单</view>
  7. <button class="btn" @click="close">关闭</button>
  8. </view>
  9. <view class="main">
  10. <view class="section flex flex-column info">
  11. <view class="info-title">{{ orderData.title }}</view>
  12. <view class="flex info-amount">¥<text class="highlight">{{ orderData.amount }}</text></view>
  13. </view>
  14. <view class="section flex payment">
  15. <view class="flex">
  16. <image class="payment-icon" src="@/pages_order/static/order/icon-wx.png" mode="widthFix"></image>
  17. <view class="payment-text">微信</view>
  18. </view>
  19. <view>
  20. <uv-radio-group
  21. :value="1"
  22. shape="circle"
  23. size="36rpx"
  24. iconSize="36rpx"
  25. activeColor="#7451DE"
  26. >
  27. <uv-radio :name="1"></uv-radio>
  28. </uv-radio-group>
  29. </view>
  30. </view>
  31. <view class="section agreement">
  32. <uv-checkbox-group
  33. v-model="checkboxValue"
  34. shape="circle"
  35. >
  36. <uv-checkbox
  37. size="36rpx"
  38. icon-size="36rpx"
  39. activeColor="#7451DE"
  40. :name="1"
  41. ></uv-checkbox>
  42. </uv-checkbox-group>
  43. <view class="desc">
  44. 我已阅读并同意
  45. <!-- todo: 替换配置项key -->
  46. <text class="highlight" @click="$refs.modal.open('config_privacy', '应用内支付用户协议')">应用内支付用户协议</text>
  47. <!-- todo: 替换配置项key -->
  48. <text class="highlight" @click="$refs.modal.open('config_agreement', '支付与隐私的声明')">支付与隐私的声明</text>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="flex footer">
  53. <button class="flex btn btn-cancel" @click="onCancel">暂不支付</button>
  54. <button class="flex btn btn-pay" @click="onPay">支付</button>
  55. </view>
  56. </view>
  57. </uv-popup>
  58. <agreementModal ref="modal" @confirm="onConfirmAgreement"></agreementModal>
  59. </view>
  60. </template>
  61. <script>
  62. export default {
  63. data() {
  64. return {
  65. orderData: {}
  66. }
  67. },
  68. methods: {
  69. async open(data) {
  70. try {
  71. const {
  72. id,
  73. title,
  74. list,
  75. addressId,
  76. amount,
  77. } = data || {}
  78. let wxPayParams
  79. if (id) {
  80. wxPayParams = await this.$fetch('payOrder', { id })
  81. } else {
  82. // todo: check is the time to create order?
  83. // todo: check 415 Unsupported Media Type
  84. wxPayParams = await this.$fetch('createOrder', { list, addressId })
  85. }
  86. this.orderData = {
  87. title,
  88. amount,
  89. wxPayParams,
  90. }
  91. console.log('orderData', this.orderData)
  92. this.$refs.popup.open()
  93. } catch (err) {
  94. }
  95. },
  96. close() {
  97. this.$refs.popup.close()
  98. },
  99. onCancel() {
  100. // todo: jump to order list page?
  101. uni.redirectTo({
  102. url: `/order/orderList/index`
  103. });
  104. // uni.navigateTo({
  105. // url: `/order/orderList/index`
  106. // });
  107. this.close()
  108. },
  109. onConfirmAgreement(confirm) {
  110. if (confirm) {
  111. this.checkboxValue = [1]
  112. } else {
  113. this.checkboxValue = []
  114. }
  115. },
  116. async onPay() {
  117. if(!this.checkboxValue.length){
  118. return uni.showToast({
  119. title: '请先同意《应用内支付用户协议》《支付与隐私的声明》',
  120. icon:'none'
  121. })
  122. }
  123. // todo: check pay
  124. await uni.requestPaymentWxPay(this.orderData.wxPayParams)
  125. this.$emit('submitted')
  126. uni.showToast({
  127. title: '支付成功',
  128. icon: 'none'
  129. })
  130. setTimeout(() => {
  131. // todo: check jump to order list page ?
  132. uni.redirectTo({
  133. url: `/order/orderList/index`
  134. });
  135. }, 700)
  136. },
  137. },
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .popup__view {
  142. width: 100vw;
  143. display: flex;
  144. flex-direction: column;
  145. box-sizing: border-box;
  146. background: #FFFFFF;
  147. border-top-left-radius: 32rpx;
  148. border-top-right-radius: 32rpx;
  149. }
  150. .header {
  151. position: relative;
  152. width: 100%;
  153. padding: 24rpx 0;
  154. box-sizing: border-box;
  155. border-bottom: 2rpx solid #EEEEEE;
  156. .title {
  157. font-family: PingFang SC;
  158. font-weight: 500;
  159. font-size: 34rpx;
  160. line-height: 1.4;
  161. color: #181818;
  162. }
  163. .btn {
  164. font-family: PingFang SC;
  165. font-weight: 500;
  166. font-size: 32rpx;
  167. line-height: 1.4;
  168. color: #8B8B8B;
  169. position: absolute;
  170. top: 26rpx;
  171. left: 40rpx;
  172. }
  173. }
  174. .main {
  175. padding: 64rpx 40rpx;
  176. }
  177. .section {
  178. margin-top: 24rpx;
  179. }
  180. .info {
  181. row-gap: 8rpx;
  182. &-title {
  183. font-family: PingFang SC;
  184. font-weight: 400;
  185. font-size: 28rpx;
  186. line-height: 1.4;
  187. color: #000000;
  188. }
  189. &-amount {
  190. font-family: PingFang SC;
  191. font-weight: 500;
  192. font-size: 24rpx;
  193. line-height: 1.4;
  194. color: #7451DE;
  195. .highlight {
  196. font-size: 64rpx;
  197. margin-left: 8rpx;
  198. }
  199. }
  200. }
  201. .payment {
  202. justify-content: space-between;
  203. box-sizing: border-box;
  204. padding: 24rpx 32rpx;
  205. background: #FAFAFF;
  206. box-shadow: -4rpx -4rpx 20rpx 0 #FFFFFFC4,
  207. 4rpx 4rpx 20rpx 0 #AAAACC1F,
  208. 2rpx 2rpx 4rpx 0 #AAAACC40,
  209. -2rpx -2rpx 4rpx 0 #FFFFFF;
  210. border-radius: 32rpx;
  211. &-icon {
  212. width: 56rpx;
  213. height: auto;
  214. }
  215. &-text {
  216. margin-left: 16rpx;
  217. font-family: PingFang SC;
  218. font-weight: 400;
  219. font-size: 28rpx;
  220. line-height: 1.5;
  221. color: #252545;
  222. }
  223. }
  224. .agreement {
  225. margin-top: 24rpx;
  226. display: flex;
  227. .desc {
  228. font-family: PingFang SC;
  229. font-size: 24rpx;
  230. font-weight: 400;
  231. line-height: 1.4;
  232. color: #8B8B8B;
  233. }
  234. .highlight {
  235. color: $uni-color;
  236. }
  237. }
  238. .footer {
  239. width: 100%;
  240. // todo:check
  241. // height: 214rpx;
  242. padding: 32rpx 40rpx;
  243. box-sizing: border-box;
  244. border-top: 2rpx solid #F1F1F1;
  245. column-gap: 32rpx;
  246. .btn {
  247. flex: 1;
  248. font-family: PingFang SC;
  249. font-weight: 500;
  250. font-size: 36rpx;
  251. line-height: 1.4;
  252. border-radius: 41rpx;
  253. &-cancel {
  254. padding: 14rpx 0;
  255. color: #252545;
  256. border: 2rpx solid #252545;
  257. }
  258. &-pay {
  259. padding: 16rpx 0;
  260. color: #FFFFFF;
  261. background-image: linear-gradient(to right, #4B348F, #845CFA);
  262. }
  263. }
  264. }
  265. </style>