alipay.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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 fx-r ">
  68. <input type="number" v-model="form.verify" placeholder-class="input-placeholder" style="width: 186px;" placeholder="请输入验证码" />
  69. <view class="fx-g1"></view>
  70. <view v-if="verifyCount <= 0" class="sbtn" @tap="getVcode">验证码</view>
  71. <view v-else class="no-sbtn">{{ verifyCount }} S</view>
  72. </view>
  73. </view>
  74. <view class="item fx-r fx-bc">
  75. <view class="label">收款码</view>
  76. <view class="value" @tap="upImg" >
  77. <image src="/static/img/upimg.png" v-if="form.img == ''" class="img"></image>
  78. <image :src="form.img" v-else mode="aspectFill" class="img"></image>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="foot">
  83. <view class="btn ihover" @tap="tapSubmit">保存</view>
  84. </view>
  85. </view>
  86. </template>
  87. <script>
  88. import {mapState,mapMutations} from 'vuex';
  89. export default {
  90. computed: mapState(['user']),
  91. data() {
  92. return {
  93. form : {
  94. img : "",
  95. name : ""
  96. },
  97. verifyCount : 0,
  98. type : 2
  99. }
  100. },
  101. onLoad(options) {
  102. this.getData();
  103. },
  104. methods: {
  105. getData:function(e){
  106. uni.showLoading({ title: '获取数据中..' });
  107. var that = this;
  108. this
  109. .request
  110. .post("getBankItem",{type : this.type})
  111. .then(res => {
  112. uni.hideLoading();
  113. if(res.code == 200) {
  114. if(res.data != null) this.form = res.data;
  115. } else {
  116. that.utils.Tip(res.msg);
  117. }
  118. }).catch(res => {
  119. uni.hideLoading();
  120. that.utils.Tip(res.msg);
  121. });
  122. },
  123. getVcode: function() {
  124. if (this.verifyCount > 0) return;
  125. uni.showLoading({ title: "获取中..."});
  126. this
  127. .request
  128. .post("userYzm",{type : "bank"})
  129. .then(res => {
  130. uni.hideLoading();
  131. if (res.code == 200) {
  132. if (res.data.status == 2) {
  133. this.utils.CountDowm(res.data.time, (e, s) => {
  134. this.verifyCount = e;
  135. });
  136. }
  137. if (res.data.status == 1) {
  138. this.utils.CountDowm(120, (e, s) => {
  139. this.verifyCount = e;
  140. });
  141. }
  142. } else {
  143. uni.showToast({
  144. title: res.msg,
  145. mask: true,
  146. icon: 'none'
  147. });
  148. }
  149. })
  150. .catch(err => {
  151. uni.showToast({
  152. title: '获取失败',
  153. mask: true,
  154. icon: 'none'
  155. });
  156. uni.hideLoading();
  157. });
  158. },
  159. upImg(){
  160. // #ifdef APP-PLUS
  161. this.$store.dispatch('permission/requestPermissions', 'WRITE_EXTERNAL_STORAGE').then(res => {
  162. if(res !== 1) return;
  163. this.upImgS();
  164. });
  165. return;
  166. // #endif
  167. this.upImgS();
  168. },
  169. upImgS() {
  170. uni.chooseImage({
  171. count: 1,
  172. sizeType: ['compressed'],
  173. success: (res) => {
  174. let img = res.tempFilePaths[0];
  175. this.utils.loadIng();
  176. this
  177. .request
  178. .post("qiniu")
  179. .then(res=>{
  180. uni.uploadFile({
  181. url: 'https://up-z0.qiniup.com',
  182. filePath: img,
  183. name: 'file',
  184. formData: {
  185. 'key': res.data.mk_str,
  186. 'token': res.data.token
  187. },
  188. success: (uploadFileRes) => {
  189. uni.hideLoading();
  190. if(uploadFileRes.statusCode == 200) {
  191. this.form.img = res.data.url;
  192. } else {
  193. this.utils.Tip("上传失败,请重新尝试," + JSON.stringify(uploadFileRes));
  194. }
  195. },
  196. fail:()=>{
  197. uni.hideLoading();
  198. this.utils.Tip("上传失败,请重新尝试");
  199. }
  200. });
  201. })
  202. .catch(err=>{
  203. uni.hideLoading();
  204. this.utils.Tip("请重新上传图片");
  205. });
  206. }
  207. });
  208. },
  209. tapSubmit:function(e){
  210. if(this.form.name == ""){
  211. uni.showToast({
  212. title:"请输入真实姓名",icon:"none",mask:true
  213. })
  214. return;
  215. }
  216. if(this.form.payment == ""){
  217. uni.showToast({
  218. title:"请输入支付宝账号",icon:"none",mask:true
  219. })
  220. return;
  221. }
  222. if (this.form.verify == '') {
  223. uni.showToast({
  224. title: '请输入验证码',
  225. mask: true,
  226. icon: 'none'
  227. });
  228. return;
  229. }
  230. uni.showLoading({ title: '提交数据中..' });
  231. this.request
  232. .post("bankSave",{
  233. ...this.form,
  234. type : this.type
  235. })
  236. .then(res=>{
  237. uni.hideLoading();
  238. if(res.code == 200) {
  239. uni.navigateBack();
  240. } else {
  241. uni.showToast({ title:res.msg,icon:"none",mask:true});
  242. }
  243. })
  244. .catch(res=>{
  245. uni.hideLoading();
  246. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  247. });
  248. }
  249. }
  250. }
  251. </script>