SecurityVerify.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <div>
  3. <nav-bar path="index" title="身份验证"/>
  4. <div class='card'>
  5. <h3><strong>个人资料</strong></h3>
  6. <van-cell-group :border="false">
  7. <van-field
  8. v-model="phone"
  9. required
  10. clearable
  11. label="手机号"
  12. placeholder="请输入手机号"
  13. :error="phoneError"
  14. @click="phoneError=false"
  15. />
  16. <!--<van-field-->
  17. <!--v-model="sms"-->
  18. <!--center-->
  19. <!--clearable-->
  20. <!--label="短信验证码"-->
  21. <!--placeholder="请输入短信验证码"-->
  22. <!--required-->
  23. <!--disabled-->
  24. <!--&gt;-->
  25. <!--<van-button slot="button" size="small" type="primary">发送验证码</van-button>-->
  26. <!--</van-field>-->
  27. <van-field
  28. v-model="username"
  29. required
  30. clearable
  31. label="昵称"
  32. placeholder="请输入昵称"
  33. maxlength="12"
  34. :error="usernameError"
  35. @click="usernameError=false"
  36. />
  37. <van-field
  38. v-model="wechat"
  39. required
  40. clearable
  41. label="微信号"
  42. placeholder="请输入微信号"
  43. maxlength="20"
  44. :error="wechatError"
  45. @click="wechatError=false"
  46. />
  47. </van-cell-group>
  48. <p>性别</p>
  49. <van-radio-group v-model="radio">
  50. <van-radio name="1" checked-color="#fd6740" style="float: left; margin-right: 20px">男</van-radio>
  51. <van-radio name="2" checked-color="#fd6740">女</van-radio>
  52. </van-radio-group>
  53. <p>宿舍区</p>
  54. <van-button size="large" @click="show = true">{{dormitory}}</van-button>
  55. <van-actionsheet
  56. v-model="show"
  57. :actions="actions"
  58. cancel-text="取消"
  59. @select="onSelect"
  60. />
  61. </div>
  62. <div class="card" style="margin-bottom: 10px">
  63. <p>上传校卡照片</p>
  64. <div style="margin-bottom: 10px">
  65. <add-photo @onRead="onRead"/>
  66. </div>
  67. <p>活动仅允许深大学生参与,请上传正面校卡照片审核~</p>
  68. </div>
  69. <van-button
  70. class="submit_button"
  71. type="primary"
  72. @click="next"
  73. :loading="loading"
  74. >下一步
  75. </van-button>
  76. </div>
  77. </template>
  78. <script>
  79. import {BasicFunction} from "../connector/basic-service";
  80. import NavBar from '../components/navBar';
  81. import {
  82. Uploader, Icon,
  83. CellGroup, Field,
  84. RadioGroup, Radio,
  85. Picker,
  86. Button,
  87. Actionsheet,
  88. Toast
  89. } from 'vant';
  90. import AddPhoto from "../components/addPhoto";
  91. export default {
  92. name: "SecurityVerify",
  93. components: {
  94. AddPhoto,
  95. NavBar,
  96. [Uploader.name]: Uploader, [Icon.name]: Icon,
  97. [CellGroup.name]: CellGroup, [Field.name]: Field,
  98. [RadioGroup.name]: RadioGroup, [Radio.name]: Radio,
  99. [Picker.name]: Picker,
  100. [Button.name]: Button,
  101. [Actionsheet.name]: Actionsheet
  102. },
  103. data() {
  104. return {
  105. phone: '',
  106. phoneError: false,
  107. sms: '',
  108. username: '',
  109. usernameError: false,
  110. wechat: '',
  111. wechatError: false,
  112. radio: '1',
  113. show: false,
  114. dormitory: '点击选择宿舍区',
  115. dorId: -1,
  116. actions: [
  117. {id: 0, name: '斋区'},
  118. {id: 1, name: '西南'},
  119. {id: 2, name: '南区'},
  120. {id: 3, name: '桂庙'},
  121. {id: 4, name: '西丽'},
  122. ],
  123. photo: null,
  124. loading: false
  125. };
  126. },
  127. methods: {
  128. next() {
  129. this.loading = true;
  130. // 检查输入
  131. if (this.phone.length !== 11) {
  132. Toast.fail("请输入11位手机号");
  133. this.phoneError = true;
  134. this.loading = false;
  135. return;
  136. } else if (this.username.length < 1) {
  137. this.usernameError = true;
  138. this.loading = false;
  139. return;
  140. } else if (this.wechat.length < 6) {
  141. this.wechatError = true;
  142. Toast.fail('请输入正确格式的微信号');
  143. this.loading = false;
  144. return;
  145. } else if (this.dorId === -1) {
  146. Toast.fail('请选择宿舍区');
  147. this.loading = false;
  148. return;
  149. } else if (this.photo === null) {
  150. Toast.fail('请上传校卡正面照片');
  151. this.loading = false;
  152. return;
  153. }
  154. let that = this;
  155. // console.log('------- photo -------');
  156. // console.log(this.photo);
  157. let formData = new FormData();
  158. formData.append('file', this.photo);
  159. BasicFunction.get_data("http://gift.fogice.com/server/fileserver/upload?sign=abcdefg", function (res) {
  160. // console.log('----- upload photo result -----');
  161. // console.log(res);
  162. if (res.model.length === 0) {
  163. Toast.fail('上传失败,请重试');
  164. return;
  165. }
  166. if (res.ret === '10000') {
  167. let imgURL = res.model; // TODO: 把imgurl也加入用户信息
  168. let userId = localStorage.getItem('frontend-userid');
  169. // console.log('----- User Identity -----');
  170. BasicFunction.get_data("smartIdentity/list?userId=" + userId, function (res) {
  171. if (res.ret === '10000') {
  172. let useridentity = res.model.list[0];
  173. useridentity.userWxAccount = that.wechat;
  174. useridentity.dormDistrict = that.dorId;
  175. useridentity.userSex = parseInt(that.radio);
  176. useridentity.userSchoolCardPic = imgURL;
  177. useridentity.userReviewStatus = 100;
  178. useridentity.reviewerNote = "未审核";
  179. useridentity.reviewerNoteToUser = "未审核";
  180. BasicFunction.get_data("smartIdentity/updateBatch", function (response) {
  181. // console.log(useridentity);
  182. // console.log(response);
  183. if (response.ret === "10000") {
  184. // console.log('----- User Info -----');
  185. BasicFunction.get_data('smartUsers/list?uid=' + userId, function (res) {
  186. // console.log(res);
  187. if (res.ret === '10000') {
  188. let user = res.model.list[0];
  189. user.name = that.username;
  190. user.phone = that.phone;
  191. // console.log('----- Update User Info -----');
  192. // console.log(user);
  193. BasicFunction.get_data('smartUsers/updateBatch', function (res) {
  194. // console.log(res);
  195. if (res.ret === '10000') {
  196. Toast.success("注册成功");
  197. that.$router.push('presentRegister');
  198. } else {
  199. Toast.fail('注册失败');
  200. that.loading = false;
  201. }
  202. }, [user]);
  203. } else {
  204. Toast.fail('获取用户信息失败');
  205. that.loading = false;
  206. }
  207. }, {});
  208. } else {
  209. Toast.fail("注册失败,请检查网络");
  210. that.loading = false;
  211. }
  212. }, [useridentity]);
  213. } else {
  214. Toast.fail('获取信息失败');
  215. }
  216. }, {});
  217. } else {
  218. Toast.fail('上传图片失败,请检查网络');
  219. that.loading = false;
  220. }
  221. }, formData);
  222. },
  223. onSelect(item) {
  224. // 点击选项时默认不会关闭菜单,可以手动关闭
  225. this.show = false;
  226. this.dormitory = item.name;
  227. this.dorId = item.id;
  228. },
  229. onRead(e) {
  230. this.photo = e;
  231. }
  232. },
  233. created: function () {
  234. let userid = localStorage.getItem('frontend-userid');
  235. let that = this;
  236. BasicFunction.get_data('smartUsers/list?uid=' + userid, function (res) {
  237. // console.log('----- User Info ----- ' + userid);
  238. // console.log(res);
  239. if (res.ret === '10000') {
  240. if (res.model.list[0].phone.length !== 0) that.$router.push('presentRegister');
  241. }
  242. }, {});
  243. }
  244. }
  245. </script>
  246. <style scoped>
  247. p, h3 {
  248. color: #fd6740;
  249. }
  250. h3 {
  251. padding: 5px;
  252. border-bottom: solid 1px #e4e4e4;
  253. }
  254. .card {
  255. background-color: white;
  256. margin: 20px 20px;
  257. border: solid 1px #e4e4e4;
  258. padding: 15px;
  259. text-align: left;
  260. }
  261. .submit_button {
  262. margin-bottom: 10px;
  263. margin-left: auto;
  264. margin-right: auto;
  265. background-color: #fd6740;
  266. border-color: #fd6740;
  267. width: 85%;
  268. }
  269. </style>