payment.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <Theme>
  3. <view class="wrap">
  4. <Navbar title="支付方式" fixed border>
  5. <template #right>
  6. <navMenu :options="{ icon: 'icon-home', text: '主页' }" />
  7. </template>
  8. </Navbar>
  9. <view class="content">
  10. <view class="cont">
  11. <view class="payable_price">
  12. {{ symbol.title }}{{ symbol.symbol }}
  13. <text>{{ money }}</text>
  14. </view>
  15. <!-- <view class="logistics_step">
  16. <trans _t="请在" />
  17. <text class="step_time">{{ useGlobal().$format(payInfo.enddate || '') }}</text>
  18. <trans _t="取消付款提示" />
  19. </view> -->
  20. <view class="wallet_pay">
  21. <view class="wallet_title">
  22. <trans _t="用余额支付" />
  23. <view class="tag">
  24. <trans _t="推荐" />
  25. </view>
  26. </view>
  27. <view class="wallet_content">
  28. <view class="wallet_top">
  29. <up-radio-group
  30. v-model="radioValue"
  31. activeColor="var(--primary)"
  32. >
  33. <up-radio name="wallet" />
  34. </up-radio-group>
  35. <view class="wallet_img">
  36. <image
  37. src="../../static/shop/balance.png"
  38. class="_img"
  39. ></image>
  40. </view>
  41. <view class="payment_text">
  42. <view class="payment_title">
  43. <trans _t="钱包" />
  44. </view>
  45. <view class="wallet_amount">¥{{ userInfo.money }}</view>
  46. </view>
  47. </view>
  48. <view class="wallet_bottom" v-if="differenceMoney < 0">
  49. <view class="bottom_left">
  50. <trans _t="余额不足需充值" />
  51. <text class="money">¥{{ Math.abs(differenceMoney) }}</text>
  52. </view>
  53. <view class="bottom_right">
  54. <trans _t="充值" />
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="footer">
  61. <view class="handling_fee">
  62. <trans _t="手续费" />&nbsp;:&nbsp;¥0
  63. </view>
  64. <view class="amount">
  65. <text>{{ symbol.title }}</text>
  66. <text>{{ symbol.symbol }}</text>
  67. <text>{{ money }}</text>
  68. </view>
  69. <view class="footer_btn" @click="paySubmit">
  70. <trans _t="支付" />
  71. <text>{{ symbol.title }}</text>
  72. <text>{{ symbol.symbol }}</text>
  73. <text>{{ money }}</text>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </Theme>
  79. </template>
  80. <script setup>
  81. import Navbar from "@/components/navbar";
  82. import navMenu from "@/components/nav_menu";
  83. import { onLoad } from "@dcloudio/uni-app";
  84. import { ref, nextTick, computed } from "vue";
  85. import { SHOP_PACKAGES_PAY } from "@/api";
  86. import { useSystemStore, useUserStore, useTabbarStore } from "@/store";
  87. import { useGlobal, Toast } from "@/utils";
  88. const useSystem = useSystemStore();
  89. const useUser = useUserStore();
  90. const useTabbar = useTabbarStore();
  91. const oid = ref("");
  92. const money = ref("");
  93. const payInfo = ref({});
  94. const radioValue = ref("wallet");
  95. const symbol = computed(() => useSystem.getSymbol);
  96. const userInfo = computed(() => useUser.getuserInfo);
  97. const differenceMoney = computed(() => {
  98. let infoPrice = Number(userInfo.value.money);
  99. let payPrice = Number(money.value);
  100. if (infoPrice > payPrice || infoPrice == payPrice) {
  101. return 0;
  102. } else {
  103. return infoPrice - payPrice;
  104. }
  105. });
  106. const paySubmit = async () => {
  107. try {
  108. const res = await SHOP_PACKAGES_PAY({
  109. id: oid.value,
  110. payType: radioValue.value,
  111. });
  112. Toast(res.msg, 1000).then(() => {
  113. setTimeout(() => {
  114. uni.navigateBack();
  115. }, 1000);
  116. });
  117. } catch (error) {
  118. Toast(error.msg);
  119. }
  120. };
  121. onLoad((options) => {
  122. oid.value = options.id;
  123. money.value = options.money;
  124. });
  125. </script>
  126. <style lang="less" scoped>
  127. @import url("@/style.less");
  128. .wrap {
  129. min-height: 100vh;
  130. background-color: var(--bg);
  131. .flex();
  132. flex-direction: column;
  133. overflow: hidden;
  134. .content {
  135. flex-grow: 1;
  136. .flex();
  137. flex-direction: column;
  138. height: calc(100vh - 44px);
  139. overflow: hidden scroll;
  140. .cont {
  141. flex-grow: 1;
  142. overflow: hidden scroll;
  143. .payable_price {
  144. color: var(--text);
  145. .size(48rpx);
  146. font-weight: 700;
  147. line-height: 60rpx;
  148. padding-top: 24rpx;
  149. text-align: center;
  150. }
  151. .logistics_step {
  152. color: var(--text-01);
  153. .size(28rpx);
  154. line-height: 40rpx;
  155. padding: 32rpx 24rpx 0;
  156. .step_time {
  157. margin: 0 8rpx;
  158. display: inline-block;
  159. color: var(--text);
  160. font-weight: 700;
  161. }
  162. }
  163. .wallet_pay {
  164. margin: 24rpx;
  165. padding: 24rpx;
  166. border-radius: 16rpx;
  167. background-color: var(--light);
  168. .wallet_title {
  169. .ver();
  170. .size(36rpx);
  171. font-weight: 700;
  172. height: 60rpx;
  173. color: var(--text);
  174. .tag {
  175. background-color: var(--danger);
  176. border-radius: 8rpx;
  177. color: var(--light);
  178. .size(24rpx);
  179. font-weight: 500;
  180. line-height: 40rpx;
  181. margin-left: 8rpx;
  182. padding: 0 8rpx;
  183. }
  184. }
  185. .wallet_content {
  186. margin-top: 24rpx;
  187. .wallet_top {
  188. /deep/ .u-radio-group {
  189. flex: none;
  190. .u-radio__icon-wrap {
  191. margin-right: 0;
  192. }
  193. }
  194. .ver();
  195. .wallet_img {
  196. width: 72rpx;
  197. height: 72rpx;
  198. margin: 0 24rpx;
  199. ._img {
  200. width: inherit;
  201. height: inherit;
  202. }
  203. }
  204. .payment_text {
  205. .ver(flex-end);
  206. color: var(--text);
  207. .size();
  208. font-weight: 500;
  209. .wallet_amount {
  210. margin-left: 8rpx;
  211. font-weight: 700;
  212. }
  213. }
  214. }
  215. .wallet_bottom {
  216. margin-top: 16rpx;
  217. padding: 16rpx 24rpx;
  218. background-color: var(--bg);
  219. border-radius: 8rpx;
  220. .flex_position(space-between);
  221. .bottom_left {
  222. color: var(--text-02);
  223. .size(24rpx);
  224. margin-right: 16rpx;
  225. .money {
  226. color: var(--primary);
  227. }
  228. }
  229. .bottom_right {
  230. height: 64rpx;
  231. background-color: var(--light);
  232. color: var(--primary);
  233. border: 1px solid var(--primary);
  234. border-radius: 16rpx;
  235. padding: 16rpx 30rpx;
  236. .flex_center();
  237. .size(24rpx);
  238. line-height: 1;
  239. }
  240. }
  241. }
  242. }
  243. }
  244. .footer {
  245. padding: 0 24rpx 24rpx;
  246. background-color: var(--bg);
  247. .handling_fee {
  248. color: var(--text-01);
  249. .size(28rpx);
  250. line-height: 60rpx;
  251. text-align: center;
  252. }
  253. .amount {
  254. color: var(--primary);
  255. .size(48rpx);
  256. font-weight: 700;
  257. line-height: 80rpx;
  258. text-align: center;
  259. }
  260. &_btn {
  261. background-color: var(--primary);
  262. color: var(--light);
  263. padding: 16rpx 30rpx;
  264. height: 96rpx;
  265. .flex_center();
  266. border-radius: 16rpx;
  267. font-weight: 700;
  268. .size(28rpx);
  269. column-gap: 8rpx;
  270. }
  271. }
  272. }
  273. }
  274. </style>