userInfo.vue 23 KB

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