123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <template>
- <div class="card" style="margin-bottom: 20px">
- <van-row>
- <van-col span="14">
- <h3><strong>个人资料</strong></h3>
- </van-col>
- <van-col span="6" style="">
- <p style="border-bottom: solid 1px #e4e4e4" @click="toggleReadOnly()">{{isReadonly ? "编辑" : "保存"}}</p>
- </van-col>
- </van-row>
- <p>昵称</p>
- <van-cell-group>
- <van-field
- placeholder=" "
- v-model="personName"
- :error="personError"
- @click="personError=false"
- required
- maxlength="10"
- :readonly="isReadonly"
- />
- </van-cell-group>
- <p>性别</p>
- <van-radio-group v-model="gender">
- <van-radio name="0" checked-color="#fd6740" style="float: left; margin-right: 20px" :disabled="isReadonly"
- >男</van-radio>
- <van-radio name="1" checked-color="#fd6740" :disabled="isReadonly"
- >女</van-radio>
- </van-radio-group>
- <p>微信号</p>
- <van-cell-group>
- <van-field
- placeholder=" "
- v-model="weixinName"
- :error="weixinError"
- @click="weixinError=false"
- required
- maxlength="20"
- :readonly="isReadonly"
- />
- </van-cell-group>
- <p>宿舍区</p>
- <van-radio-group v-model="dormDistrict">
- <van-radio name="0" checked-color="#fd6740" style="float: left; margin-right: 20px" :disabled="isReadonly">南区</van-radio>
- <van-radio name="1" checked-color="#fd6740" style="float: left; margin-right: 20px" :disabled="isReadonly">西南</van-radio>
- <van-radio name="2" checked-color="#fd6740" style="float: left; margin-right: 20px" :disabled="isReadonly">斋区</van-radio>
- <van-radio name="3" checked-color="#fd6740" style="float: left; margin-right: 20px" :disabled="isReadonly">桂庙</van-radio>
- <van-radio name="4" checked-color="#fd6740" :disabled="isReadonly">西丽</van-radio>
- </van-radio-group>
- </div>
- </template>
- <script>
- import { Row, Col,
- CellGroup, Field,
- RadioGroup, Radio,
- } from 'vant';
- import {BasicFunction} from "../connector/basic-service";
- export default {
- name: "schoolidCard",
- components: {
- [CellGroup.name]: CellGroup, [Field.name]: Field,
- [RadioGroup.name]: RadioGroup, [Radio.name]: Radio,
- [Row.name]: Row, [Col.name]: Col,
- },
- data() {
- return {
- gender: '0',
- dormDistrict: '1',
- personName: '',
- personError: false,
- weixinName: '',
- weixinError: false,
- isReadonly: true,
- userDo: {},
- reviewDo: {},
- }
- },
- methods: {
- uploadNameChange: function () {
- BasicFunction.get_data("smartUsers/updateBatch", function (response) {
- console.log("------ Data Rcvd in PresentReg --------");
- console.log(response);
- if (response.ret === "10000") {
- history.go(0);
- } else {
- // 注册失败的处理
- Toast.fail("上传失败,请检查网络");
- }
- }, [this.userDo]);
- },
- uploadReviewChange: function () {
- BasicFunction.get_data("smartIdentity/updateBatch", function (response) {
- console.log("------ Data Rcvd in PresentReg --------");
- console.log(response);
- if (response.ret === "10000") {
- history.go(0);
- } else {
- // 注册失败的处理
- Toast.fail("上传失败,请检查网络");
- }
- }, [this.reviewDo]);
- },
- toggleReadOnly: function () {
- if (!this.isReadonly){
- this.savePage()
- }
- this.isReadonly = !this.isReadonly;
- },
- savePage() {
- // 检验输入
- // var userId = localStorage.getItem(....
- if (this.personName.length === 0) {
- this.personError = true;
- return;
- } else if (this.weixinName.length >= 20) {
- this.weixinError = true;
- Toast.fail('最多输入20个字符');
- return;
- }
- // post_present()
- this.userDo.name = this.weixinName;
- this.uploadNameChange();
- this.reviewDo.gender = this.gender;
- this.reviewDo.dormDistrict = this.dormDistrict;
- this.uploadReviewChange();
- },
- getIdentityInfo: function (obj) {
- //this;
- var userId = localStorage.getItem("frontend-userid");
- window.schoolIdCard = this;
- BasicFunction.get_data("smartUsers/list?uid=" + userId, function (response) {
- console.log("------ Data Rcvd in PresentReg --------");
- console.log(response);
- if (response.ret === "10000") {
- var t = response.model.list;
- window.schoolIdCard.personName = t[0].name; // 左侧是vue页面内的变量名字, 右侧是后台数据里的变量名称
- window.schoolIdCard.userDo = t[0];
- } else {
- // 注册失败的处理
- Toast.fail("获取失败,请检查网络");
- }
- }, [{}]);
- },
- getReviewInfo:function (obj) {
- var userId = localStorage.getItem("frontend-userid");
- window.schoolIdCard = this;
- BasicFunction.get_data("smartIdentity/list?userId=" + userId, function (response) {
- console.log("------ Data Rcvd in PresentReg --------");
- console.log(response);
- if (response.ret === "10000") {
- var t = response.model.list;
- window.schoolIdCard.gender = t[0].userSex; // 左侧是vue页面内的变量名字, 右侧是后台数据里的变量名称
- window.schoolIdCard.dormDistrict = t[0].dormDistrict;
- window.schoolIdCard.reviewDo = t[0];
- } else {
- Toast.fail("获取失败,请检查网络");
- }
- }, [{}]);
- }
- },
- created: function () {
- window.schoolIdCard = this;
- this.getIdentityInfo(window.schoolIdCard);
- this.getReviewInfo(window.schoolIdCard);
- }
- }
- </script>
- <style scoped>
- p, h3 {
- color: #fd6740;
- }
- h3 {
- padding: 5px;
- border-bottom: solid 1px #e4e4e4;
- }
- p {
- padding-top: 3px;
- }
- .card {
- background-color: white;
- margin: 20px 20px;
- border: solid 1px #e4e4e4;
- padding: 15px;
- text-align: left;
- }
- </style>
|