userInfo.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. <template>
  2. <view>
  3. <uni-nav-bar id="nav-bar" status-bar="true" @clickLeft="onBack()" :title="pageTitle" color="#000000" fixed="true"
  4. :border="false">
  5. <view slot="left">
  6. <view v-if="!bNewUser" class=" flex align-center margin-left">
  7. <image class="p-left-arrow" src="../../../static/p-left-arrow.png"></image>
  8. </view>
  9. </view>
  10. <view v-if="bNewUser" slot="right">
  11. <text class="text-df text-purple margin-right-sm" @tap="onNavUser">下一步</text>
  12. </view>
  13. </uni-nav-bar>
  14. <view class="card-view">
  15. <view class="avatar-group" @tap="ChooseImage">
  16. <view class="avatar-size ">
  17. <!-- 保持纵横比缩放图片 -->
  18. <image class="avatar-img round bg-black" mode="aspectFit" :src="changeData.avatarUrl"></image>
  19. <image class="avatar-tag " src="/static/camera.png"></image>
  20. </view>
  21. <view class="text-upload">
  22. <text>请上传头像</text>
  23. </view>
  24. </view>
  25. <view class="item-group flex align-center">
  26. <view class="text-grey padding-sm margin-name text-width ">
  27. 昵称
  28. </view>
  29. <input maxlength="8" placeholder="输入名字" :value="changeData.userName" @input="onInput('name',$event)"></input>
  30. </view>
  31. <view class="item-group flex align-center" @tap="showModal" data-target="showPickerModal" data-type="gender">
  32. <view class="text-grey padding-sm margin-name text-width flex">性别
  33. <view v-if="bNewUser" style="position: relative; width: 4px;">
  34. <!-- <view class="cu-tag badge"></view> -->
  35. </view>
  36. </view>
  37. <view class="text-bold">{{changeData.gender==0?'男':'女'}}</view>
  38. </view>
  39. <view class="item-group flex align-center" @tap="showModal" data-target="showPickerModal" data-type="birthday">
  40. <view class="text-grey padding-sm margin-name text-width flex">生日
  41. <view v-if="bNewUser" style="position: relative; width: 4px;">
  42. <!-- <view class="cu-tag badge"></view> -->
  43. </view>
  44. </view>
  45. <view class="text-bold">{{changeData.sBirthday}}</view>
  46. </view>
  47. <view class="item-group flex align-center" @tap="showModal" data-target="showPickerModal" data-type="city">
  48. <view class="text-grey padding-sm margin-name text-width flex">城市
  49. <view v-if="bNewUser" style="position: relative; width: 4px;">
  50. <!-- <view class="cu-tag badge"></view> -->
  51. </view>
  52. </view>
  53. <view class="text-bold">{{changeData.city.label}}</view>
  54. </view>
  55. <view class="flex justify-start ">
  56. <view class="text-grey padding-sm margin-name text-width flex-shrink">个性签名</view>
  57. <textarea class="sign-text text-bold" maxlength="50" placeholder="在这里留下你的签名吧!" :value="changeData.signature!=='null'?changeData.signature:''"
  58. @input="onInput('signature',$event)"></textarea>
  59. </view>
  60. </view>
  61. <view class="card-view margin-top ">
  62. <view class="cu-item shadow padding-top padding-bottom">
  63. <view class="content">
  64. <view class="item-group" @tap="showModal" data-target="showPickerModal" data-type="height">
  65. <view class="text-grey padding-sm margin-name text-width flex">身高
  66. <view v-if="bNewUser" style="position: relative; width: 4px;">
  67. <!-- <view class="cu-tag badge"></view> -->
  68. </view>
  69. </view>
  70. <view class="text-bold">{{changeData.height}} cm</view>
  71. </view>
  72. <view class="item-group" @tap="showModal" data-target="showPickerModal" data-type="weight">
  73. <view class="text-grey padding-sm margin-name text-width flex">体重
  74. <view v-if="bNewUser" style="position: relative; width: 4px;">
  75. <!-- <view class="cu-tag badge"></view> -->
  76. </view>
  77. </view>
  78. <view class="text-bold">{{changeData.weight}} 公斤</view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <view class="card-view margin-top">
  84. <view class="cu-item shadow padding-top-sm padding-bottom-sm flex justify-between">
  85. <view class="content">
  86. <view class="item-group">
  87. <view class="text-grey padding-sm margin-name text-width flex">手机
  88. </view>
  89. <view class="text-bold">{{phoneNumber!==''?phoneNumber:'未绑定' }}</view>
  90. </view>
  91. </view>
  92. <view class="right-container" @tap="onBindPhone">
  93. <image style="width: 48rpx;height: 48rpx;" src="/static/bindPhone.png"></image>
  94. <text class="text-grey text-sm" style="margin: 0 24rpx;">{{phoneNumber!==''?'已绑定':'去绑定'}}</text>
  95. <view class="only-arrow"></view>
  96. </view>
  97. </view>
  98. </view>
  99. <view v-if="bInstallWechat&&!bHideWeixin" class="card-view margin-top ">
  100. <view class="cu-item shadow padding-top-sm padding-bottom-sm flex justify-between">
  101. <view class="content">
  102. <view class="item-group">
  103. <view class="text-grey padding-sm margin-name text-width flex">微信
  104. </view>
  105. <view class="text-bold">{{openid!==''?'已关联微信':'未关联微信'}} </view>
  106. </view>
  107. </view>
  108. <view class="right-container" @tap="onBindWeixin">
  109. <image style="width: 48rpx;height: 48rpx;" src="/static/img/weixin_b.png"></image>
  110. <text class="text-grey text-sm" style="margin: 0 24rpx;">{{openid!==''?'已绑定':'去绑定'}}</text>
  111. <view class="only-arrow"></view>
  112. </view>
  113. </view>
  114. </view>
  115. <view v-if="!bNewUser" class="flex justify-center" style="margin: 32px 0 32px 0;">
  116. <view class="btn-confirm" @tap="onNavUser">保存</view>
  117. </view>
  118. <view class="cu-modal bottom-modal" :class="modalName=='showPickerModal'?'show':''" @touchmove.stop.prevent="moveHandle">
  119. <view class="cu-dialog" style="border-top-right-radius: 20rpx; border-top-left-radius: 20rpx;">
  120. <myPicker v-if="modalName == 'showPickerModal' ? true:false" :pickerObj="pickerObj" @confirmEvent="onConfirm"
  121. @cancelEvent="hideModal">
  122. </myPicker>
  123. </view>
  124. </view>
  125. <view class="cu-modal" :class="modalName=='showBindModal'?'show':''" @touchmove.stop.prevent="moveHandle">
  126. <view class="cu-bind-modal">
  127. <view style="position: absolute; top: 0; left: 0; width: 100%; height:100%;">
  128. <image style="position: absolute;top: 0;left: 0; width: 100%;height: 100%;" src="../../../static/modelBg.png"></image>
  129. </view>
  130. <view class="flex flex-direction justify-between " style="position: relative; height: 100%;">
  131. <view class="flex justify-around justify-center align-center" style="margin: 170rpx 30rpx 0 30rpx;">
  132. <view style="width: 80rpx;height: 2rpx;border-radius: 2px; background-color: #cbcdcf;"></view>
  133. <view class="make-text-bPurple" style=" font-size: 20px;">{{bindModal.title}}</view>
  134. <view style="width: 80rpx;height: 2rpx;border-radius: 2px;background-color: #cbcdcf;"></view>
  135. </view>
  136. <view class="text-16px">{{bindModal.content}}</view>
  137. <view class="flex justify-around align-center" style=" border-top: 1rpx solid #EEEEEE; margin-bottom: 2px;">
  138. <view class="flex justify-center align-center text-16px" style="width: 100%;height: 123rpx;" @tap="hideModal">稍后再说</view>
  139. <view style="height: 123rpx;width: 1px;background-color: #EEEEEE;"></view>
  140. <view class="flex justify-center align-center text-16px" style="width: 100%;height: 123rpx;" @tap="hideBindModal">确定</view>
  141. </view>
  142. </view>
  143. </view>
  144. </view>
  145. </view>
  146. </template>
  147. <script>
  148. import myPicker from '@/components/slambb-picker/slambb-picker.vue';
  149. import pickerData from '@/components/slambb-picker/picker.js';
  150. import config from '@/common/config.js';
  151. import reqUtil from "@/util/util-js/requstUtil.js";
  152. import date from "@/util/util-js/date.js";
  153. import {
  154. mapState,
  155. mapMutations
  156. } from 'vuex'
  157. export default {
  158. computed: mapState(['bNewUser', 'height', 'weight', 'userName', 'avatarUrl', 'days', 'signature', "gender",
  159. 'birthday', 'city', 'phoneNumber', 'openid','bInstallWechat','bHideWeixin'
  160. ]),
  161. components: {
  162. myPicker
  163. },
  164. data() {
  165. let pickerObj = {
  166. pickerLeftList: pickerData.getWeightList().leftList,
  167. pickerRightList: pickerData.getWeightList().rightList,
  168. pickerType: "doubleItem",
  169. pickerUnit: "斤",
  170. pickerTitle: "记体重",
  171. defaultValue: 0
  172. };
  173. return {
  174. modalName: null,
  175. //选择器对象
  176. pickerObj,
  177. bChoose: false,
  178. // oldData: null,
  179. changeData:null,
  180. //是否可以更新
  181. bCanUpdate: false,
  182. pageTitle: "完善资料",
  183. bLoading: false,
  184. bindModal: {
  185. title: '解绑',
  186. content: '绑定账号可以快速登录'
  187. }
  188. }
  189. },
  190. onLoad() {
  191. let s = this.birthday.replace(/-/g, "/");
  192. var dateTemp = new Date(s);
  193. // this.oldData = {
  194. // 'height': this.height,
  195. // 'weight': this.weight,
  196. // 'userName': this.userName,
  197. // 'avatarUrl': this.avatarUrl,
  198. // 'signature': this.signature,
  199. // "gender": this.gender,
  200. // "cityCode": this.city.cityCode,
  201. // 'birthday': this.birthday,
  202. // "city":this.city,
  203. // "sBirthday": date.formatDate(dateTemp)
  204. // };
  205. this.changeData = {
  206. 'height': this.height,
  207. 'weight': this.weight,
  208. 'userName': this.userName,
  209. 'avatarUrl': this.avatarUrl,
  210. 'signature': this.signature,
  211. "gender": this.gender,
  212. "cityCode": this.city.cityCode,
  213. 'birthday': this.birthday,
  214. "city":this.city,
  215. "sBirthday": date.formatDate(dateTemp)
  216. };
  217. if (this.bNewUser) {
  218. this.pageTitle = "基础资料";
  219. this.$store.state.bNewGuide = true;
  220. }
  221. },
  222. methods: {
  223. ...mapMutations(['login']),
  224. ChooseImage() {
  225. uni.chooseImage({
  226. count: 1, //默认9
  227. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  228. sourceType: ['album'], //从相册选择
  229. success: (res) => {
  230. this.bChoose = true;
  231. let size = res.tempFiles[0].size;
  232. console.log('res:',res);
  233. if(size<=10000000){
  234. this.changeData.avatarUrl = res.tempFiles[0].path;
  235. }else{
  236. uni.showToast({
  237. title:'上传的图片不能超过10M',
  238. icon:'none',
  239. })
  240. }
  241. }
  242. });
  243. },
  244. onInput(type, event) {
  245. // console.log(type, "==", event.detail.value);
  246. if (type == "name") {
  247. this.changeData.userName = event.detail.value;
  248. this.bCanUpdate = true;
  249. } else if (type == "signature") {
  250. this.changeData.signature = event.detail.value;
  251. this.bCanUpdate = true;
  252. }
  253. },
  254. /**
  255. * 由于性别和生日是有默认值,所以不用检测
  256. */
  257. onCheck() {
  258. if (this.height == 0) {
  259. uni.showToast({
  260. title: "请选择身高",
  261. icon: "none"
  262. })
  263. return false;
  264. } else
  265. if (this.weight == 0) {
  266. uni.showToast({
  267. title: "请选择体重",
  268. icon: "none"
  269. })
  270. return false;
  271. }
  272. return true;
  273. },
  274. //上传用户数据
  275. onNavUser() {
  276. let that = this;
  277. uni.showToast({
  278. title: "",
  279. icon: "loading",
  280. mask: true,
  281. duration: 10000
  282. })
  283. if (that.bLoading) return;
  284. that.bLoading = true;
  285. let data = {
  286. "filePath": this.changeData.avatarUrl,
  287. "username": this.changeData.userName,
  288. "birthday": this.changeData.birthday,
  289. "signature": this.changeData.signature,
  290. "gender": this.changeData.gender,
  291. "cityCode": this.changeData.city.cityCode,
  292. "weight": this.changeData.weight,
  293. "height": this.changeData.height,
  294. }
  295. console.log("更新时候的 data信息:",data);
  296. //如果选择了图片,用图片接口更新数据
  297. if (that.bChoose) {
  298. reqUtil.reqUpload(config.URL.USERINFOADDAVATAR, data, that.changeData.avatarUrl).then(res => {
  299. console.log('reqUpload USERINFOADDAVATAR =====', res);
  300. uni.hideToast();
  301. that.bLoading = false;
  302. if (res.code == 0) {
  303. uni.showToast({
  304. title: "更新成功",
  305. mask: true,
  306. duration: 1000
  307. })
  308. that.bChoose = false;
  309. // that.$store.state.avatarUrl = res.data.avatarUrl;
  310. that.login(res.data);
  311. // 如果是新用户,跳转首页
  312. setTimeout(() => {
  313. if (that.bNewUser) {
  314. that.$store.state.bNewUser = false;
  315. // uni.redirectTo({
  316. // url: "../../personal-page/personal/personal"
  317. // })
  318. uni.redirectTo({
  319. url:'../firstPlan/firstPlan'
  320. })
  321. } else {
  322. uni.navigateBack({
  323. delta: 1
  324. })
  325. }
  326. }, 1000);
  327. }
  328. },
  329. e => {
  330. console.log(e);
  331. that.bLoading = false;
  332. uni.showModal({
  333. title: '错误',
  334. content: '更新头像失败,是否重新更新?',
  335. confirmText: '是的',
  336. success: (res) => {
  337. if (res.confirm) {
  338. that.onNavUser();
  339. }
  340. }
  341. })
  342. });
  343. } else {
  344. //如果只修改数据,走数据接口
  345. if (!that.bNewUser && !that.bCanUpdate) {
  346. uni.showToast({
  347. title: "数据无改动",
  348. icon: "none",
  349. mask: true,
  350. duration: 1000
  351. })
  352. that.bLoading = false;
  353. return;
  354. }
  355. reqUtil.requestData(config.URL.USERINFOADD, data, "POST").then(res => {
  356. console.log('requestData USERINFOADD =====', res);
  357. uni.hideToast();
  358. that.bLoading = false;
  359. if (res.code == 0) {
  360. uni.showToast({
  361. title: "更新成功",
  362. mask: true,
  363. duration: 1000
  364. })
  365. that.bCanUpdate = false;
  366. that.login(res.data);
  367. setTimeout(() => {
  368. if (that.bNewUser) {
  369. that.$store.state.bNewUser = false;
  370. // uni.redirectTo({
  371. // url: "../../personal-page/personal/personal"
  372. // })
  373. uni.redirectTo({
  374. url:'../firstPlan/firstPlan'
  375. })
  376. } else {
  377. uni.navigateBack({
  378. delta: 1
  379. })
  380. }
  381. }, 1000);
  382. }
  383. },
  384. e => {
  385. console.log(e);
  386. that.bLoading = false;
  387. uni.showModal({
  388. title: '错误',
  389. content: '更新数据失败,是否重新更新?',
  390. confirmText: '是的',
  391. success: (res) => {
  392. if (res.confirm) {
  393. that.onNavUser();
  394. }
  395. }
  396. })
  397. });
  398. }
  399. },
  400. onBack() {
  401. uni.navigateBack({
  402. delta: 1
  403. })
  404. },
  405. showModal(e) {
  406. this.pikerType = e.currentTarget.dataset.type
  407. switch (this.pikerType) {
  408. case "weight":
  409. this.$set(this.pickerObj, 'pickerLeftList', pickerData.getWeightList().leftList);
  410. this.$set(this.pickerObj, 'pickerRightList', pickerData.getWeightList().rightList);
  411. this.$set(this.pickerObj, 'pickerType', "doubleItem");
  412. this.$set(this.pickerObj, 'pickerUnit', "公斤");
  413. this.$set(this.pickerObj, 'pickerTitle', "记体重");
  414. this.$set(this.pickerObj, 'defaultValue', this.weight);
  415. this.$set(this.pickerObj, 'showInput', true);
  416. break;
  417. case "height":
  418. this.pickerObj = {};
  419. this.$set(this.pickerObj, 'pickerLeftList', pickerData.getHeightList().leftList);
  420. // pickerData.getHeightList().rightList
  421. this.$set(this.pickerObj, 'pickerRightList', []);
  422. this.$set(this.pickerObj, 'pickerType', "singleItem");
  423. this.$set(this.pickerObj, 'pickerUnit', "厘米");
  424. this.$set(this.pickerObj, 'pickerTitle', "记身高");
  425. this.$set(this.pickerObj, 'defaultValue', this.height);
  426. this.$set(this.pickerObj, 'showInput', true);
  427. break;
  428. case "birthday":
  429. this.pickerObj = {};
  430. this.$set(this.pickerObj, 'pickerType', "dateItem");
  431. this.$set(this.pickerObj, 'pickerTitle', "记生日");
  432. this.$set(this.pickerObj, 'showInput', false);
  433. break;
  434. case "gender":
  435. this.pickerObj = {};
  436. this.$set(this.pickerObj, 'pickerLeftList', pickerData.getGenderList().genderList);
  437. this.$set(this.pickerObj, 'pickerRightList', []);
  438. this.$set(this.pickerObj, 'pickerType', "singleItem");
  439. this.$set(this.pickerObj, 'pickerTitle', "性别");
  440. this.$set(this.pickerObj, 'defaultValue', "男");
  441. this.$set(this.pickerObj, 'showInput', false);
  442. break;
  443. case "city":
  444. this.pickerObj = {};
  445. this.$set(this.pickerObj, 'pickerType', "city");
  446. this.$set(this.pickerObj, 'pickerTitle', "省市区");
  447. this.$set(this.pickerObj, 'defaultValue', this.city.value);
  448. this.$set(this.pickerObj, 'showInput', false);
  449. break;
  450. }
  451. this.modalName = e.currentTarget.dataset.target
  452. },
  453. hideModal(e) {
  454. this.modalName = null
  455. },
  456. moveHandle() {
  457. return;
  458. },
  459. onConfirm(data) {
  460. console.log(data);
  461. // let data = e.detail.__args__[0];
  462. switch (this.pikerType) {
  463. case "weight":
  464. if (data.value != this.weight) {
  465. this.bCanUpdate = true;
  466. this.changeData.weight = data.value;
  467. }
  468. break;
  469. case "height":
  470. if (data.value != this.height) {
  471. this.bCanUpdate = true;
  472. this.changeData.height = data.value;
  473. }
  474. break;
  475. case "birthday":
  476. this.bCanUpdate = true;
  477. let nDate = new Date();
  478. nDate.setFullYear(data.value[0], data.value[1] - 1, data.value[2]);
  479. this.changeData.sBirthday = date.formatDate(nDate);
  480. this.changeData.birthday = date.formatTime(nDate);
  481. break;
  482. case "gender":
  483. if (data.value != this.gender) {
  484. this.bCanUpdate = true;
  485. this.changeData.gender = data.index;
  486. }
  487. break;
  488. case "city":
  489. if (data.value.cityCode != this.cityCode) {
  490. this.bCanUpdate = true;
  491. this.changeData.city = data.value;
  492. }
  493. break;
  494. }
  495. this.hideModal();
  496. },
  497. onBindPhone() {
  498. // //TODO 弹出解绑提示
  499. // this.bindModal = {
  500. // title: '解绑',
  501. // content: '你确定要解绑手机吗?',
  502. // type: "deletePhoneNumber"
  503. // };
  504. // this.modalName = "showBindModal";
  505. if (!this.phoneNumber) {
  506. uni.navigateTo({
  507. url: "../../login-page/bindPhone/bindPhone"
  508. })
  509. } else {
  510. uni.showToast({
  511. title: '已绑定手机',
  512. icon: 'none',
  513. })
  514. }
  515. },
  516. onBindWeixin() {
  517. if (this.openid) {
  518. uni.showToast({
  519. title: '已绑定微信',
  520. icon: 'none'
  521. })
  522. } else {
  523. this.bindModal = {
  524. title: '微信绑定',
  525. content: '“哔蹦”想打开“微信”',
  526. type: 'bindWxInfo'
  527. };
  528. this.modalName = "showBindModal";
  529. }
  530. },
  531. hideBindModal() {
  532. this.modalName = null;
  533. console.log(this.bindModal);
  534. let _self = this;
  535. if (this.bindModal.type == 'bindWxInfo') {
  536. // 绑定微信
  537. // #ifdef APP-PLUS
  538. this.oauth("weixin");
  539. // #endif
  540. // #ifndef APP-PLUS
  541. uni.showToast({
  542. title: "只支持app端",
  543. icon: "none"
  544. })
  545. // #endif
  546. } else if (this.bindModal.type == 'deletePhoneNumber') {
  547. //弹框解绑手机
  548. reqUtil.requestData(config.URL.DELETEPHONE, {}).then(res => {
  549. console.log('DELETEPHONE请求返回:', res);
  550. if (res.code == 0) {
  551. uni.showToast({
  552. title: "解绑手机号成功",
  553. mask: true,
  554. duration: 1000
  555. })
  556. _self.$store.state.phoneNumber = '';
  557. } else {
  558. uni.showToast({
  559. title: "解绑手机号失败",
  560. mask: true,
  561. icon: 'none',
  562. duration: 1000
  563. })
  564. }
  565. },
  566. e => {
  567. console.log(e)
  568. });
  569. }
  570. },
  571. oauth(value) {
  572. let _self = this;
  573. uni.showToast({
  574. title: "",
  575. icon: "loading",
  576. duration: 10000
  577. })
  578. uni.login({
  579. provider: value,
  580. success: (res) => {
  581. console.log('code11:', res);
  582. // android 端绑定微信信息
  583. let wxInfo = {
  584. openid: res.authResult.openid,
  585. unionid: res.authResult.unionid
  586. };
  587. reqUtil.requestData(config.URL.BINDWXINFO, {
  588. openid: res.authResult.openid,
  589. unionid: res.authResult.unionid
  590. }).then(res => {
  591. console.log('BINDWXINFO请求返回:', res);
  592. uni.hideToast();
  593. if (res.code == 0) {
  594. uni.showToast({
  595. title: "绑定微信成功",
  596. mask: true,
  597. duration: 1000
  598. })
  599. _self.$store.state.openid = wxInfo.openid;
  600. } else if (res.code == 212) {
  601. uni.showToast({
  602. title: "此微信已被绑定,请使用其他微信",
  603. mask: true,
  604. icon: 'none',
  605. duration: 3000
  606. })
  607. // // 微信授权登录对象
  608. // let aweixin = null;
  609. // // 当前环境支持的所有授权登录对象
  610. // let auths = {};
  611. // plus.oauth.getServices(function(services) {
  612. // for (var i in services) {
  613. // auths[services[i].id] = services[i];
  614. // }
  615. // aweixin = auths['weixin'];
  616. // aweixin.logout(function(e) {
  617. // // plus.nativeUI.alert("注销登录认证成功!");
  618. // console.log("注销登录认证成功");
  619. // }, function(e) {
  620. // // plus.nativeUI.alert("注销登录认证失败: " + JSON.stringify(e));
  621. // console.log("注销登录认证失败: " + JSON.stringify(e));
  622. // });
  623. // }, function(e) {
  624. // plus.nativeUI.alert("获取登录授权服务列表失败:" + JSON.stringify(e));
  625. // });
  626. } else {
  627. uni.showToast({
  628. title: "绑定微信失败",
  629. mask: true,
  630. icon: 'none',
  631. duration: 1000
  632. })
  633. }
  634. },
  635. e => {
  636. console.log(e);
  637. uni.hideToast();
  638. });
  639. },
  640. fail: (err) => {
  641. console.error('授权登录失败:' + JSON.stringify(err));
  642. }
  643. });
  644. },
  645. }
  646. }
  647. </script>
  648. <style>
  649. .flex-shrink {
  650. flex-shrink: 0;
  651. }
  652. .avatar-group {
  653. margin-top: 30px;
  654. display: flex;
  655. flex-direction: column;
  656. justify-content: center;
  657. align-items: center;
  658. }
  659. .avatar-size {
  660. position: relative;
  661. width: 187.33rpx;
  662. height: 186.67rpx;
  663. }
  664. .avatar-img {
  665. width: 187.33rpx;
  666. height: 186.67rpx;
  667. border: 3px solid #9997fc;
  668. }
  669. .avatar-tag {
  670. position: absolute;
  671. right: 0;
  672. bottom: 0;
  673. width: 46rpx;
  674. height: 46rpx;
  675. }
  676. .text-upload {
  677. font-size: 13px;
  678. color: rgba(166, 166, 166, 1);
  679. padding: 10px 0 45px 0;
  680. }
  681. .text-width {
  682. width: 160rpx;
  683. /* background: #007AFF; */
  684. }
  685. .margin-name {
  686. margin: 0 0 0 66rpx;
  687. }
  688. .item-group {
  689. display: flex;
  690. justify-content: flex-start;
  691. align-items: center;
  692. }
  693. .item-group input {
  694. font-weight: bold;
  695. }
  696. .sign-text {
  697. margin: 20rpx 30rpx 30rpx 0;
  698. height: 4.6em;
  699. width: 100%;
  700. line-height: 1.2em;
  701. flex: 1;
  702. font-size: 28rpx;
  703. /* padding: 1rpx; */
  704. /* border: 1rpx solid #007AFF; */
  705. }
  706. /* .btn-confirm {
  707. width: 636rpx;
  708. height: 102rpx;
  709. background-color: rgba(151, 151, 255, 1);
  710. border-radius: 10px;
  711. } */
  712. .btn-confirm {
  713. width: 636rpx;
  714. height: 102rpx;
  715. background-color: rgba(151, 151, 255, 1);
  716. border-radius: 10px;
  717. display: flex;
  718. justify-content: center;
  719. align-items: center;
  720. font-size: 17px;
  721. color: #FFFFFF;
  722. }
  723. .right-container {
  724. display: flex;
  725. flex-direction: row;
  726. justify-content: center;
  727. align-items: center;
  728. }
  729. </style>