weixin.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <style lang="scss">
  2. .app-body{
  3. padding: 10px 0;
  4. .input-form {
  5. background: #fff;
  6. .item{
  7. padding: 35rpx 20rpx;
  8. border-bottom: 1px solid #f1f1f1;
  9. .label{
  10. width: 86px;
  11. font-weight: 400;
  12. color: #333;
  13. }
  14. .value{
  15. width: calc(100% - 86px);
  16. }
  17. }
  18. }
  19. }
  20. .input-placeholder {
  21. color: #999;
  22. }
  23. .sbtn{
  24. font-size: 14px;
  25. color: #DB292B;
  26. margin-right: 10rpx;
  27. }
  28. .no-sbtn{
  29. font-size: 14px;
  30. color: #999999;
  31. margin-right: 10rpx;
  32. }
  33. .foot{
  34. padding: 40rpx 60rpx;
  35. }
  36. .btn{
  37. background: #DB292B;
  38. border-radius: 60rpx;
  39. text-align: center;
  40. font-weight: bold;
  41. font-size: 28rpx;
  42. padding: 30rpx 0;
  43. color: #FAFAFA;
  44. }
  45. .img{
  46. width: 160rpx;
  47. height: 160rpx;
  48. }
  49. </style>
  50. <template>
  51. <view class="app-body">
  52. <view class="input-form">
  53. <view class="item fx-r fx-bc">
  54. <view class="label">真实姓名</view>
  55. <view class="value">
  56. <input type="text" v-model="form.name" placeholder-class="input-placeholder" placeholder="请输入真实姓名" />
  57. </view>
  58. </view>
  59. <view class="item fx-r fx-bc">
  60. <view class="label">微信号</view>
  61. <view class="value">
  62. <input type="text" v-model="form.payment" placeholder-class="input-placeholder" placeholder="请输入微信号" />
  63. </view>
  64. </view>
  65. <view class="item fx-r fx-bc">
  66. <view class="label">手机号码</view>
  67. <view class="value">
  68. <input type="number" v-model="form.phone" placeholder-class="input-placeholder" placeholder="请输入手机号码" />
  69. </view>
  70. </view>
  71. <view class="item fx-r fx-bc">
  72. <view class="label">验证码</view>
  73. <view class="value fx-r ">
  74. <input type="number" v-model="form.verify" placeholder-class="input-placeholder" style="width: 186px;" placeholder="请输入验证码" />
  75. <view class="fx-g1"></view>
  76. <view v-if="verifyCount <= 0" class="sbtn" @tap="getVcode">验证码</view>
  77. <view v-else class="no-sbtn">{{ verifyCount }} S</view>
  78. </view>
  79. </view>
  80. <view class="item fx-r fx-bc">
  81. <view class="label">收款码</view>
  82. <view class="value" @tap="upImg" >
  83. <image src="/static/img/upimg.png" v-if="form.img == ''" class="img"></image>
  84. <image :src="form.img" v-else mode="aspectFill" class="img"></image>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="foot">
  89. <view class="btn ihover" @tap="tapSubmit">保存</view>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. import {mapState,mapMutations} from 'vuex';
  95. export default {
  96. computed: mapState(['user']),
  97. data() {
  98. return {
  99. form : {
  100. img : "",
  101. name : "",
  102. phone : ""
  103. },
  104. verifyCount : 0,
  105. type : 1
  106. }
  107. },
  108. onLoad(options) {
  109. this.getData();
  110. },
  111. methods: {
  112. getData:function(e){
  113. uni.showLoading({ title: '获取数据中..' });
  114. var that = this;
  115. this
  116. .request
  117. .post("getBankItem",{type : this.type})
  118. .then(res => {
  119. uni.hideLoading();
  120. if(res.code == 200) {
  121. if(res.data != null) this.form = res.data;
  122. } else {
  123. that.utils.Tip(res.msg);
  124. }
  125. }).catch(res => {
  126. uni.hideLoading();
  127. that.utils.Tip(res.msg);
  128. });
  129. },
  130. getVcode: function() {
  131. if (this.verifyCount > 0) return;
  132. uni.showLoading({ title: "提交数据中..."});
  133. this
  134. .request
  135. .post("userYzm",{type : "bank"})
  136. .then(res => {
  137. uni.hideLoading();
  138. if (res.code == 200) {
  139. if (res.data.status == 2) {
  140. this.utils.CountDowm(res.data.time, (e, s) => {
  141. this.verifyCount = e;
  142. });
  143. }
  144. if (res.data.status == 1) {
  145. this.utils.CountDowm(120, (e, s) => {
  146. this.verifyCount = e;
  147. });
  148. }
  149. } else {
  150. uni.showToast({
  151. title: res.msg,
  152. mask: true,
  153. icon: 'none'
  154. });
  155. }
  156. })
  157. .catch(err => {
  158. uni.showToast({
  159. title: '获取失败',
  160. mask: true,
  161. icon: 'none'
  162. });
  163. uni.hideLoading();
  164. });
  165. },
  166. upImg() {
  167. uni.chooseImage({
  168. count: 1,
  169. sizeType: ['compressed'],
  170. success: (res) => {
  171. let img = res.tempFilePaths[0];
  172. this.utils.loadIng();
  173. this
  174. .request
  175. .post("qiniu")
  176. .then(res=>{
  177. uni.uploadFile({
  178. url: 'https://up-z0.qiniup.com',
  179. filePath: img,
  180. name: 'file',
  181. formData: {
  182. 'key': res.data.mk_str,
  183. 'token': res.data.token
  184. },
  185. success: (uploadFileRes) => {
  186. uni.hideLoading();
  187. if(uploadFileRes.statusCode == 200) {
  188. this.form.img = res.data.url;
  189. } else {
  190. this.utils.Tip("上传失败,请重新尝试," + JSON.stringify(uploadFileRes));
  191. }
  192. },
  193. fail:()=>{
  194. uni.hideLoading();
  195. this.utils.Tip("上传失败,请重新尝试");
  196. }
  197. });
  198. })
  199. .catch(err=>{
  200. uni.hideLoading();
  201. this.utils.Tip("请重新上传图片");
  202. });
  203. }
  204. });
  205. },
  206. tapSubmit:function(e){
  207. if(this.form.name == ""){
  208. uni.showToast({
  209. title:"请输入真实姓名",icon:"none",mask:true
  210. })
  211. return;
  212. }
  213. if(this.form.payment == ""){
  214. uni.showToast({
  215. title:"请输入微信号",icon:"none",mask:true
  216. })
  217. return;
  218. }
  219. if(this.form.phone == ""){
  220. uni.showToast({
  221. title:"请输入手机号码",icon:"none",mask:true
  222. })
  223. return;
  224. }
  225. if (this.form.verify == '') {
  226. uni.showToast({
  227. title: '请输入验证码',
  228. mask: true,
  229. icon: 'none'
  230. });
  231. return;
  232. }
  233. uni.showLoading({ title: '提交数据中..' });
  234. this.request
  235. .post("bankSave",{
  236. ...this.form,
  237. type : this.type
  238. })
  239. .then(res=>{
  240. uni.hideLoading();
  241. if(res.code == 200) {
  242. uni.navigateBack();
  243. } else {
  244. uni.showToast({ title:res.msg,icon:"none",mask:true});
  245. }
  246. })
  247. .catch(res=>{
  248. uni.hideLoading();
  249. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  250. });
  251. }
  252. }
  253. }
  254. </script>