wx.vue 6.0 KB

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