becomeVip.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <view class="center">
  3. <view class="info-box">
  4. <view class="info-item flex">
  5. <view class="info-item-left">姓名:</view>
  6. <view class="info-item-right"><input type="text" v-model="name" placeholder="请输入您的姓名" placeholder-class="placeholder" /></view>
  7. </view>
  8. <view class="info-item flex">
  9. <view class="info-item-left">性别:</view>
  10. <view class="info-item-right">
  11. <picker @change="bindPickerSex" :range="array">
  12. <view>{{ sex }}</view>
  13. </picker>
  14. </view>
  15. </view>
  16. <view class="info-item flex">
  17. <view class="info-item-left">联系方式:</view>
  18. <view class="info-item-right"><input type="number" v-model="phone" placeholder="请输入您的手机号" placeholder-class="placeholder" /></view>
  19. </view>
  20. <view class="info-item flex">
  21. <view class="info-item-left">验证码:</view>
  22. <view class="info-item-right"><input type="number" v-model="code" placeholder="请输入您的验证码" placeholder-class="placeholder" /></view>
  23. <view class="info-item-yzm" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  24. </view>
  25. </view>
  26. <view class="upload">
  27. <view class="upload-title">身份证正反面</view>
  28. <view class="upload-main">
  29. <view class="add-img-box flex_item">
  30. <view class="add-img-item" v-for="(item, index) in imgList" :key="index">
  31. <image class="add-img" @click.stop="imgInfo(index)" :src="item" mode="aspectFill"></image>
  32. <image class="add-img-del" @click.stop="delImg(index)" src="/static/img/delete.png"></image>
  33. </view>
  34. <view v-for="(item, index) in 2 - imgList.length" class="add-img-item" @click.stop="scImg()"><image class="add-img" src="/static/img/add.png"></image></view>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="btn" @click="add()">提交申请</view>
  39. </view>
  40. </template>
  41. <script>
  42. import { upload, apply } from '@/api/order.js';
  43. import { verify } from '@/api/login.js';
  44. export default {
  45. data() {
  46. return {
  47. name: '',
  48. sex: '请选择您的性别',
  49. phone: '',
  50. code: '',
  51. countDown: 0, //倒计时
  52. array: ['男', '女'],
  53. imgList: [],
  54. imgCount: 2 //最多支持9张上传,可以修改
  55. };
  56. },
  57. watch: {
  58. // 监听倒计时
  59. countDown(i) {
  60. if (i == 0) {
  61. clearInterval(this.time);
  62. }
  63. }
  64. },
  65. methods: {
  66. scImg() {
  67. let obj = this;
  68. console.log(obj.imgCount, 11);
  69. if (obj.imgCount == 0) {
  70. uni.showToast({
  71. title: '最多添加2张图片',
  72. icon: 'none'
  73. });
  74. return;
  75. }
  76. upload({
  77. file: ''
  78. })
  79. .then(e => {
  80. console.log(e[0].url, 'e');
  81. obj.imgList.push(e[0].url);
  82. console.log(obj.imgList, 'imgList');
  83. obj.imgCount = 2 - obj.imgList.length;
  84. console.log(obj.imgCount, 'imgCount ');
  85. })
  86. .catch(e => {});
  87. },
  88. // 选择性别
  89. bindPickerSex: function(e) {
  90. console.log(this.array[e.target.value]);
  91. this.sex = this.array[e.target.value];
  92. },
  93. //点击图片显示大图
  94. imgInfo(i) {
  95. let tempList = [];
  96. console.log(111);
  97. this.imgList.forEach(e => {
  98. tempList.push(e);
  99. });
  100. console.log(tempList);
  101. //显示图片
  102. uni.previewImage({
  103. current: i,
  104. loop: false,
  105. urls: tempList,
  106. indicator: 'default'
  107. });
  108. },
  109. //删除图片
  110. delImg(i) {
  111. uni.showModal({
  112. content: '确定删除这张吗',
  113. success: res => {
  114. if (res.confirm) {
  115. this.imgList.splice(i, 1);
  116. this.imgCount++;
  117. } else if (res.cancel) {
  118. }
  119. }
  120. });
  121. },
  122. verification() {
  123. let obj = this;
  124. if (this.phone == '') {
  125. this.$api.msg('请输入联系方式');
  126. return;
  127. }
  128. if (this.phone.length < 11) {
  129. this.$api.msg('请输入正确的手机号');
  130. return;
  131. }
  132. // 判断是否在倒计时
  133. if (obj.countDown > 0) {
  134. return false;
  135. } else {
  136. obj.countDown = 60;
  137. obj.time = setInterval(() => {
  138. obj.countDown--;
  139. }, 1000);
  140. //调用验证码接口
  141. verify({
  142. phone: obj.phone,
  143. type: 'register'
  144. })
  145. .then(({ data }) => {})
  146. .catch(err => {
  147. console.log(err);
  148. });
  149. }
  150. },
  151. // 提交申请
  152. add() {
  153. const obj = this;
  154. if (obj.name == '') {
  155. return this.$api.msg('请输入你的姓名');
  156. }
  157. if (obj.sex == '') {
  158. return this.$api.msg('请输入你的姓别');
  159. }
  160. if (obj.phone == '') {
  161. return this.$api.msg('请输入你的联系方式');
  162. }
  163. if (this.phone.length < 11) {
  164. this.$api.msg('请输入正确的联系方式');
  165. return;
  166. }
  167. if (obj.code == '') {
  168. return this.$api.msg('请输入你的验证码');
  169. }
  170. if (obj.imgList.length == 0) {
  171. return this.$api.msg('请上传你的身份证照片');
  172. }
  173. apply({ name: obj.name, sex: obj.sex == '男' ? 1 : 2, phone: obj.phone, images: obj.imgList, captcha: obj.code }).then(e => {
  174. uni.navigateTo({
  175. url: '/pages/order/success?type=2'
  176. });
  177. });
  178. }
  179. }
  180. };
  181. </script>
  182. <style lang="scss">
  183. page,
  184. .center {
  185. min-height: 100%;
  186. height: auto;
  187. background: #f2f3f5;
  188. }
  189. .info-box {
  190. width: 690rpx;
  191. margin: 20rpx auto 0;
  192. background: #ffffff;
  193. border-radius: 10rpx;
  194. .info-item {
  195. justify-content: flex-start;
  196. padding: 38rpx 20rpx;
  197. .info-item-left {
  198. width: 140rpx;
  199. font-size: 28rpx;
  200. font-family: PingFang SC;
  201. font-weight: 500;
  202. color: #333333;
  203. }
  204. .info-item-right {
  205. margin-left: 70rpx;
  206. width: 260rpx;
  207. font-size: 28rpx;
  208. font-family: PingFang SC;
  209. font-weight: 500;
  210. color: #999999;
  211. .placeholder {
  212. font-size: 28rpx;
  213. font-family: PingFang SC;
  214. font-weight: 500;
  215. color: #999999;
  216. }
  217. }
  218. .info-item-yzm {
  219. margin-left: 100rpx;
  220. font-size: 28rpx;
  221. font-family: PingFang SC;
  222. font-weight: 500;
  223. color: #ff6f0f;
  224. }
  225. }
  226. }
  227. .upload-image {
  228. width: 160rpx;
  229. height: 160rpx;
  230. border-radius: 10rpx;
  231. }
  232. .upload-title {
  233. font-size: 30rpx;
  234. font-family: PingFang SC;
  235. font-weight: bold;
  236. color: #333333;
  237. }
  238. .upload-main {
  239. padding-top: 32rpx;
  240. display: flex;
  241. justify-content: center;
  242. align-items: center;
  243. flex-direction: column;
  244. .upload-font {
  245. margin-top: 24rpx;
  246. font-size: 30rpx;
  247. font-family: PingFang SC;
  248. font-weight: bold;
  249. color: #333333;
  250. }
  251. }
  252. .upload {
  253. width: 690rpx;
  254. margin: 20rpx auto 0;
  255. padding: 34rpx 30rpx 40rpx 30rpx;
  256. background: #ffffff;
  257. .add-img-box {
  258. width: 100%;
  259. flex-direction: row;
  260. flex-wrap: wrap;
  261. margin-top: 50rpx;
  262. }
  263. .add-img-item {
  264. width: 180rpx;
  265. height: 180rpx;
  266. border-radius: 24rpx;
  267. position: relative;
  268. margin: 0rpx 20rpx;
  269. margin-bottom: 25rpx;
  270. .add-img {
  271. width: 100%;
  272. height: 100%;
  273. }
  274. }
  275. }
  276. .add-img-del {
  277. position: absolute;
  278. width: 40rpx;
  279. height: 40rpx;
  280. left: 155rpx;
  281. bottom: 155rpx;
  282. //background-color: rgba(238, 0, 0, 1);
  283. border-radius: 20rpx;
  284. }
  285. .btn {
  286. position: fixed;
  287. bottom: 0;
  288. width: 750rpx;
  289. height: 98rpx;
  290. background: #24a17d;
  291. text-align: center;
  292. font-size: 36rpx;
  293. font-family: PingFang SC;
  294. font-weight: 500;
  295. color: #ffffff;
  296. line-height: 98rpx;
  297. }
  298. </style>