index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view style="z-index: 999;">
  3. <uni-popup ref="popup" :is-mask-click="false" borderRadius="10px 10px 0 0" background-color="#eee">
  4. <view class="popup-content">
  5. <view class="popup-content-close">
  6. <view class="icon" @tap="handleClose">
  7. <uni-icons
  8. type="closeempty"
  9. color="#999"
  10. size="24"
  11. />
  12. </view>
  13. </view>
  14. <view class="popup-content-main">
  15. <view class="popup-content-main-count">
  16. <view class="title">{{ title }}</view>
  17. <view class="pay">
  18. <uni-icons color="#000" type="icon-renminbi1688" size="16" custom-prefix="iconfont"></uni-icons>
  19. <view>{{ amount }}</view>
  20. </view>
  21. </view>
  22. <view class="popup-content-main-type">
  23. <view v-if="payTypeList?.length" class="card">
  24. <radio-group @change="radioChange">
  25. <label class="card-label" v-for="item in payTypeList" :key="item.value">
  26. <view class="name">
  27. <uni-icons :color="item.color" class="mr-1" :type="item.icon" size="24" custom-prefix="iconfont"></uni-icons>
  28. {{item.name}}
  29. </view>
  30. <view>
  31. <radio :value="item.value" :disabled="item.disabled" :checked="item.value === channelValue" />
  32. </view>
  33. </label>
  34. </radio-group>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="popup-content-btn">
  39. <button class="popup-content-btn-s" @tap="handlePay">
  40. 确认支付
  41. <uni-icons color="#FFF" type="icon-renminbi1688" size="16" custom-prefix="iconfont"></uni-icons>
  42. {{ amount }}
  43. </button>
  44. </view>
  45. </view>
  46. </uni-popup>
  47. </view>
  48. </template>
  49. <script setup>
  50. import { ref } from 'vue'
  51. import { getEnableCodeList } from '@/api/common'
  52. const props = defineProps({
  53. title: { // 标题
  54. type: String,
  55. default: '支付'
  56. },
  57. amount: { // 支付金额
  58. type: [String, Number],
  59. default: '金额获取失败'
  60. },
  61. })
  62. const payType = [
  63. {
  64. name: '微信支付',
  65. value: 'wx_lite',
  66. icon: 'icon-weixinzhifu',
  67. color: '#1AAD19'
  68. },
  69. {
  70. name: '钱包支付',
  71. value: 'wallet',
  72. disabled: true,
  73. icon: 'icon-qianbao1',
  74. color: '#00B760'
  75. }
  76. ]
  77. // 余额和其他还没有接暂时只支持微信支付
  78. const payTypeList = ref([])
  79. // 获取支付方式
  80. const getPayMethodsList = async () => {
  81. payTypeList.value = []
  82. try {
  83. const res = await getEnableCodeList({appId: 14})
  84. if (!res?.data?.length) {
  85. return
  86. }
  87. payTypeList.value.push(...payType.filter(e => res.data.includes(e.value)))
  88. const result = payType.find(item => !item.disabled && item.value)
  89. if (result) channelValue.value = result.value
  90. } catch (error) {
  91. console.log(error)
  92. }
  93. }
  94. getPayMethodsList()
  95. const channelValue = ref('')
  96. const radioChange = (e) => {
  97. channelValue.value = e?.detail?.value || ''
  98. }
  99. const tabBarControl = (show = false) => { // 显示/隐藏TabBar
  100. const currentPage = getCurrentPages()
  101. if (!currentPage) return
  102. const currentTabBar = currentPage[0]?.getTabBar?.()
  103. currentTabBar?.setData({ show })
  104. }
  105. const popup = ref()
  106. const handleClose = () => {
  107. tabBarControl(true)
  108. popup.value.close()
  109. }
  110. const handleOpen = () => {
  111. tabBarControl(false)
  112. popup.value.open('bottom')
  113. }
  114. // 支付
  115. const handlePay = async () => {
  116. }
  117. defineExpose({
  118. handleOpen
  119. })
  120. </script>
  121. <style lang="scss" scoped>
  122. .pay {
  123. position: sticky;
  124. bottom: 0;
  125. padding: 0 40rpx 50rpx 40rpx;
  126. box-sizing: border-box;
  127. &-box {
  128. width: 100%;
  129. background: linear-gradient(121deg,#fde2c2 29.02%,#c19164 104.03%);
  130. border-radius: 180rpx 0 180rpx 0;
  131. box-shadow: 3rpx 6rpx 10rpx 0rpx rgb(216 160 82);
  132. display: flex;
  133. justify-content: space-between;
  134. align-items: center;
  135. height: 100rpx;
  136. .price {
  137. padding: 0 40rpx;
  138. font-size: 40rpx;
  139. font-weight: 600;
  140. color: #e68735;
  141. }
  142. .btn {
  143. height: 100%;
  144. display: flex;
  145. align-items: center;
  146. padding: 0 40rpx;
  147. border: 2rpx solid #00B760;
  148. background: #00B760;
  149. color: #FFF;
  150. border-radius: 180rpx 0 180rpx 0;
  151. position: relative;
  152. // &::after {
  153. // content: '';
  154. // position: absolute;
  155. // width: 50rpx;
  156. // height: 50rpx;
  157. // background: radial-gradient(top right, transparent 50%, #00B760 50%);
  158. // left: 0;
  159. // top: 0;
  160. // margin-left: -25rpx;
  161. // border-radius: 180rpx;
  162. // }
  163. }
  164. }
  165. }
  166. .popup-content {
  167. z-index: 999;
  168. max-height: 500px;
  169. display: flex;
  170. flex-direction: column;
  171. &-close {
  172. display: flex;
  173. padding: 10px;
  174. justify-content: flex-end;
  175. .icon {
  176. width: 30px;
  177. height: 30px;
  178. background: #ccc;
  179. border-radius: 30px;
  180. display: flex;
  181. align-items: center;
  182. justify-content: center;
  183. }
  184. }
  185. &-main {
  186. flex: 1;
  187. height: 0;
  188. overflow-y: auto;
  189. &-count {
  190. margin-bottom: 20px;
  191. text-align: center;
  192. .title {
  193. font-size: 28rpx;
  194. color: #666
  195. }
  196. .pay {
  197. font-size: 52rpx;
  198. color: #000;
  199. font-weight: 600;
  200. display: flex;
  201. align-items: center;
  202. justify-content: center;
  203. padding: 10px 0;
  204. }
  205. }
  206. &-type {
  207. width: 100%;
  208. padding: 0 20px;
  209. box-sizing: border-box;
  210. .card {
  211. border-radius: 10px;
  212. margin: 0 auto;
  213. background: #FFF;
  214. padding: 10px;
  215. &-label {
  216. padding: 15px 0;
  217. box-sizing: border-box;
  218. display: flex;
  219. justify-content: space-between;
  220. border-bottom: 1px solid #eee;
  221. &:last-of-type {
  222. border-bottom: none;
  223. }
  224. .name {
  225. display: flex;
  226. align-items: center;
  227. color: #333;
  228. }
  229. }
  230. }
  231. }
  232. }
  233. &-btn {
  234. height: 70px;
  235. width: 100%;
  236. margin-top: 10px;
  237. display: flex;
  238. align-items: center;
  239. justify-content: center;
  240. &-s {
  241. height: 40px;
  242. width: 75%;
  243. line-height: 40px;
  244. color: #FFF;
  245. // color: #724d2b;
  246. background: #00B760;
  247. // background: linear-gradient(121deg,#fde2c2 29.02%,#c19164 104.03%);
  248. border-radius: 90px;
  249. }
  250. }
  251. }
  252. .mr-1 {
  253. margin-right: 10px;
  254. }
  255. </style>