exchange-hint.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <view>
  3. <u-popup v-model="show" mode="bottom" :border-radius="'50'">
  4. <view class="popup-box">
  5. <view class="title">
  6. <text class="title-btn"></text>
  7. <text class="title-text">请输入密码</text>
  8. <text class="title-btn cancel-btn iconfont3" @click.stop="show = false">&#xe6e6;</text>
  9. </view>
  10. <view class="content-box">
  11. <view class="content-notarize">
  12. 确认将:
  13. </view>
  14. <view class="content-nums">
  15. <template v-if="type === 1 || type === 0">
  16. <text class="iconfont3 content-nums-icon">&#xe619;</text>
  17. <text class="content-nums-text">{{ useNums }}积分</text>
  18. </template>
  19. <template v-else-if="type === 2">
  20. <text class="iconfont content-nums-icon">¥</text>
  21. <text class="content-nums-text">{{ useNums }}元</text>
  22. </template>
  23. </view>
  24. <view class="content-result">
  25. {{ result[type]}}
  26. </view>
  27. <view class="content-result-num" style="margin-top: 10px;">
  28. <text>{{ resultNum }}</text>
  29. </view>
  30. <view class="content-password">
  31. <u-message-input :focus="true" :breathe="false" dot-fill :maxlength="maxlength"
  32. :value="pay_password" @change="changePassword"></u-message-input>
  33. </view>
  34. <view class="content-btns">
  35. <view class="content-btn notarize-btn" @click.stop="givePresent()">
  36. {{ notarizeBtn[type]}}
  37. </view>
  38. <view class="content-btn" @click="show = false">
  39. 取消
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </u-popup>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. name: "exchange-hint",
  50. props: {
  51. params: {
  52. type: Object,
  53. default: () => {
  54. return {
  55. url: '',
  56. mode: '',
  57. data: {}
  58. }
  59. }
  60. },
  61. type: {
  62. // 转赠/兑换类型 0:积分兑换余额;1:积分转赠;2:余额转赠
  63. type: Number,
  64. default: 0
  65. },
  66. useNums: {
  67. // 转赠 / 兑换 数量
  68. type: String | Number,
  69. default: 0
  70. },
  71. resultNum: {
  72. type: String,
  73. default: ''
  74. }
  75. },
  76. data() {
  77. return {
  78. show: false,
  79. maxlength: 6, // 密码长度
  80. pay_password: '',
  81. result: [
  82. "兑换为余额",
  83. "转赠给:",
  84. "转赠给:"
  85. ],
  86. notarizeBtn: [
  87. '确认兑换',
  88. '确认转赠',
  89. '确认转赠'
  90. ],
  91. givePresentLoading: false
  92. };
  93. },
  94. watch: {
  95. },
  96. methods: {
  97. changePassword(e) {
  98. this.pay_password = e
  99. },
  100. open() {
  101. this.show = true
  102. },
  103. givePresent() {
  104. if (this.givePresentLoading) {
  105. return false;
  106. };
  107. if (!this.pay_password) {
  108. this.$mUtil.toast("请输入支付密码")
  109. return false
  110. };
  111. if (this.pay_password.length !== this.maxlength) {
  112. this.$mUtil.toast("请确认密码是否输入完整")
  113. return false
  114. };
  115. this.givePresentLoading = true;
  116. const data = {
  117. ...this.params.data,
  118. pay_password: this.pay_password
  119. }
  120. try {
  121. this.$http[this.params.mode](this.params.url, data).then((res) => {
  122. if (res && res.code == 200) {
  123. console.log('resresres = ', res)
  124. if (this.type === 0) {
  125. this.$mUtil.toast("兑换成功")
  126. } else if (this.type === 1 || this.type === 2) {
  127. this.$mUtil.toast("转赠成功")
  128. }
  129. this.show = false;
  130. setTimeout(() => {
  131. uni.navigateBack({
  132. delta: 1
  133. })
  134. }, 1000)
  135. };
  136. this.givePresentLoading = false;
  137. }).catch(err => {
  138. this.givePresentLoading = false;
  139. })
  140. } catch (e) {
  141. this.givePresentLoading = false;
  142. }
  143. },
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. .popup-box {
  149. padding: 60rpx 60rpx 0;
  150. }
  151. .title {
  152. width: 100%;
  153. height: 68rpx;
  154. border-radius: 50rpx 50rpx 0 0;
  155. display: flex;
  156. justify-content: space-between;
  157. align-items: center;
  158. text {
  159. height: 100%;
  160. }
  161. .title-btn {
  162. width: 80rpx;
  163. text-align: right;
  164. }
  165. .cancel-btn {
  166. font-size: 50rpx;
  167. display: flex;
  168. justify-content: flex-end;
  169. }
  170. .title-text {
  171. position: relative;
  172. font-size: 36rpx;
  173. font-family: PingFang SC, PingFang SC-Bold;
  174. font-weight: 700;
  175. color: #1a1a1a;
  176. &:before {
  177. content: '';
  178. position: absolute;
  179. left: 50%;
  180. bottom: 0;
  181. width: 64rpx;
  182. height: 8rpx;
  183. background: #cccccc;
  184. transform: translateX(-50%);
  185. border-radius: 4rpx;
  186. }
  187. }
  188. }
  189. .content-box {
  190. width: 100%;
  191. .content-notarize {
  192. padding: 50rpx 0 3px;
  193. font-size: 32rpx;
  194. font-family: PingFang SC, PingFang SC-Bold;
  195. font-weight: 700;
  196. color: #333333;
  197. }
  198. .content-nums {
  199. .content-nums-icon {
  200. font-size: 45rpx;
  201. color: #000000;
  202. margin-right: 10px;
  203. }
  204. .content-nums-text {
  205. font-size: 60rpx;
  206. font-family: PingFang SC, PingFang SC-Bold;
  207. font-weight: 700;
  208. color: #1a1a1a;
  209. }
  210. }
  211. .content-result {
  212. margin-top: 61rpx;
  213. font-size: 32rpx;
  214. font-family: PingFang SC, PingFang SC-Bold;
  215. font-weight: 700;
  216. color: #333333;
  217. }
  218. .content-result-num {
  219. font-size: 28rpx;
  220. font-family: PingFang SC, PingFang SC-Regular;
  221. font-weight: 400;
  222. }
  223. .content-password {
  224. padding: 60rpx 0 76rpx;
  225. }
  226. .content-btns {
  227. width: 100%;
  228. display: flex;
  229. justify-content: space-between;
  230. align-items: center;
  231. padding-bottom: 106rpx;
  232. .content-btn {
  233. width: 298rpx;
  234. height: 85rpx;
  235. border-radius: 43rpx;
  236. color: #FA6138;
  237. background: #e7eefc;
  238. border: 1rpx solid #3775f6;
  239. text-align: center;
  240. line-height: 83rpx;
  241. }
  242. .notarize-btn {
  243. background-color: #FA6138;
  244. color: #FFFFFF;
  245. }
  246. }
  247. // <view class="content-btns">
  248. // <view class="content-btn">
  249. // 确认兑换
  250. // </view>
  251. // <view class="content-btn">
  252. // 取消
  253. // </view>
  254. // </view>
  255. }
  256. /deep/.u-char-item {
  257. background-color: #e6e6e6;
  258. border: none;
  259. }
  260. </style>