zfb.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view class="content">
  3. <view class="box">
  4. <view class="item top">
  5. <text>真实姓名</text>
  6. <input type="text" v-model="name" value="" placeholder="请输入真实姓名" />
  7. </view>
  8. <view class="item top">
  9. <text>支付宝账号</text>
  10. <input type="text" v-model="id" value="" placeholder="请输入支付宝账号" />
  11. </view>
  12. <!-- <view class="item top">
  13. <text>手机号</text>
  14. <input type="text" v-model="phone" value="" placeholder="请输入手机号" />
  15. </view> -->
  16. <view class="item top">
  17. <text>验证码</text>
  18. <view class="login_name flex">
  19. <input class="uni-input" v-model="code" focus placeholder="请输入验证码" />
  20. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  21. </view>
  22. </view>
  23. <view class="erweima">
  24. <text>收款码</text>
  25. <view class="img" @click="uploads()">
  26. <image src="../../static/user/erweima.png" mode="" v-if="image == ''"></image>
  27. <image :src="image" mode="scaleToFill" v-else></image>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="button" @click="confirm()">确认</view>
  32. <canvas canvas-id="canvas" v-if="canvasStatus"
  33. :style="{width: canvasWidth + 'px', height: canvasHeight + 'px',position: 'absolute',left:'-100000px',top:'-100000px'}"></canvas>
  34. <uni-popup ref="popup" type="center">
  35. <view class="alertprogress">
  36. {{progress}}%
  37. </view>
  38. </uni-popup>
  39. <codeImage @openCode='getCode' loginType="" @close='showAlert=false' :phone="userInfo.phone" ref="alertImage"
  40. :show='showAlert'></codeImage>
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. upload
  46. } from '@/api/order.js'
  47. import {
  48. getUserInfo
  49. } from '@/api/user.js';
  50. import {
  51. mapState,
  52. mapMutations
  53. } from 'vuex';
  54. import {
  55. auction,
  56. pay_list
  57. } from '@/api/wallet.js';
  58. import codeImage from '@/components/codeImage.vue';
  59. export default {
  60. data() {
  61. return {
  62. name: '',
  63. id: '',
  64. phone: '',
  65. countDown: 0, //倒计时
  66. code: '', //验证码
  67. time: '',
  68. image: '',
  69. upFileLoding: false,
  70. userInfo: {},
  71. canvasStatus: false,
  72. canvasWidth: 0,
  73. canvasHeight: 0,
  74. progress: 0,
  75. showAlert:false,
  76. };
  77. },
  78. components: {
  79. codeImage
  80. },
  81. watch: {
  82. // 监听倒计时
  83. countDown(i) {
  84. if (i == 0) {
  85. clearInterval(this.time);
  86. }
  87. }
  88. },
  89. onShow() {
  90. getUserInfo().then((res) => {
  91. this.userInfo = res.data;
  92. })
  93. },
  94. onLoad() {
  95. pay_list().then(({
  96. data
  97. }) => {
  98. if (data.zfb != '') {
  99. this.name = data.zfb.name
  100. this.id = data.zfb.payment
  101. this.phone = data.zfb.phone
  102. this.image = data.zfb.image
  103. }
  104. })
  105. },
  106. methods: {
  107. close() {
  108. this.showAlert = false;
  109. },
  110. // 发送验证码
  111. getCode() {
  112. const obj = this;
  113. obj.countDown = 60;
  114. obj.time = setInterval(() => {
  115. obj.countDown--;
  116. }, 1000);
  117. //调用验证码接口
  118. },
  119. uploads() {
  120. const that = this;
  121. if (that.upFileLoding) {
  122. return
  123. }
  124. that.upFileLoding = true;
  125. setTimeout(() => {
  126. that.upFileLoding = false;
  127. }, 1000);
  128. that.canvasStatus = true;
  129. upload({
  130. filename: '',
  131. file_name: 'collection/zfb/' + that.userInfo.uid
  132. }, (res) => {
  133. that.image = res[0].url;
  134. that.canvasStatus = false
  135. }, (res) => {
  136. that.canvasStatus = false
  137. }, (res) => {
  138. that.canvasWidth = res.w
  139. that.canvasHeight = res.h
  140. }, (res) => {
  141. // console.log(res,'res');
  142. if (res.progress == 100) {
  143. this.$refs.popup.close()
  144. uni.showToast({
  145. title: '上传成功'
  146. });
  147. } else if (res.progress == 0) {
  148. this.$refs.popup.open()
  149. }
  150. that.progress = res.progress;
  151. // console.log(res,'进度条');
  152. })
  153. },
  154. verification() {
  155. let obj = this;
  156. if (!this.userInfo.phone) {
  157. this.$api.msg('请绑定手机号');
  158. return;
  159. }
  160. // 判断是否在倒计时
  161. if (obj.countDown > 0) {
  162. return false;
  163. } else {
  164. obj.showAlert = true;
  165. obj.$refs.alertImage.getImage()
  166. }
  167. },
  168. confirm() {
  169. let obj = this;
  170. if (!obj.name) {
  171. return this.$api.msg('请输入提款人姓名');
  172. }
  173. if (!obj.id) {
  174. return this.$api.msg('请输入支付宝账号');
  175. }
  176. // if (!obj.phone) {
  177. // return this.$api.msg('请输入手机号码');
  178. // }
  179. if (!obj.code) {
  180. return this.$api.msg('请输入验证码');
  181. }
  182. if (!obj.image) {
  183. return this.$api.msg('请上传支付凭证');
  184. }
  185. auction({
  186. type: 2,
  187. name: obj.name,
  188. payment: obj.id,
  189. phone: obj.userInfo.phone,
  190. captcha: obj.code,
  191. image: obj.image,
  192. })
  193. .then(e => {
  194. obj.$api.msg('修改成功');
  195. uni.redirectTo({
  196. url: './collection',
  197. });
  198. })
  199. .catch(e => {
  200. console.log(e);
  201. });
  202. },
  203. }
  204. };
  205. </script>
  206. <style lang="scss">
  207. page,
  208. .content {
  209. height: 100%;
  210. padding: 0;
  211. margin: 0;
  212. }
  213. .top {
  214. border-bottom: 1rpx solid #f3f3f3;
  215. }
  216. .box {
  217. background: #ffffff;
  218. margin: 20rpx 0 70rpx 0;
  219. .item {
  220. display: flex;
  221. align-items: center;
  222. text {
  223. margin: 0 40rpx 0 25rpx;
  224. width: 150rpx;
  225. font-size: 30rpx;
  226. font-family: PingFang SC;
  227. font-weight: 400;
  228. color: #333333;
  229. line-height: 100rpx;
  230. }
  231. input {
  232. height: 100rpx;
  233. display: inline-block;
  234. font-size: 28rpx;
  235. font-family: PingFang SC;
  236. font-weight: 400;
  237. color: #999999;
  238. line-height: 100rpx;
  239. }
  240. .uni-input {
  241. text-align: left;
  242. width: 325rpx;
  243. font-size: 28rpx !important;
  244. }
  245. .login_name {
  246. color: #333333;
  247. }
  248. .code {
  249. color: #db292b;
  250. font-size: 23rpx;
  251. border-left: 1px solid #eeeeee;
  252. width: 150rpx;
  253. flex-shrink: 0;
  254. text-align: center;
  255. }
  256. }
  257. }
  258. .button {
  259. text-align: center;
  260. width: 560rpx;
  261. height: 80rpx;
  262. background: #FD3B39;
  263. border-radius: 40rpx;
  264. font-size: 30rpx;
  265. font-family: PingFangSC;
  266. font-weight: 500;
  267. color: #ffffff;
  268. line-height: 80rpx;
  269. margin: 0 auto;
  270. }
  271. .erweima {
  272. padding: 30rpx 0;
  273. display: flex;
  274. text {
  275. margin: 0 30rpx;
  276. width: 150rpx;
  277. font-size: 30rpx;
  278. font-family: PingFang SC;
  279. font-weight: 400;
  280. color: #333333;
  281. }
  282. .img {
  283. width: 160rpx;
  284. height: 160rpx;
  285. image {
  286. width: 100%;
  287. height: 100%;
  288. }
  289. }
  290. }
  291. </style>