index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <view class="container">
  3. <view class="brand">
  4. <image :src="fetch.avatar" @click="avatarSet(0)" class="avatar"></image>
  5. <avatar @upload="avatarUpload" ref="avatar"></avatar>
  6. <view class="username">{{fetch.name}}</view>
  7. </view>
  8. <view class="user-form">
  9. <list-cell line-right padding="30rpx">
  10. <view class="form-item">
  11. <view class="label">昵称</view>
  12. <input type="text" v-model="fetch.name"/>
  13. </view>
  14. </list-cell>
  15. <list-cell line-right padding="30rpx">
  16. <view class="form-item">
  17. <view class="label">头衔</view>
  18. <input type="text" v-model="fetch.title"/>
  19. </view>
  20. </list-cell>
  21. <list-cell line-right padding="30rpx">
  22. <view class="form-item">
  23. <view class="label">签名</view>
  24. <input type="text" v-model="fetch.info"/>
  25. </view>
  26. </list-cell>
  27. <list-cell line-right padding="30rpx" style="display: none;">
  28. <view class="form-item">
  29. <view class="label">手机号码</view>
  30. <input type="text" v-model="fetch.mobile" />
  31. <button type="default" plain class="font-size-sm" @tap="showTelphoneModal">更换手机</button>
  32. </view>
  33. </list-cell>
  34. <list-cell line-right padding="30rpx">
  35. <view class="form-item">
  36. <view class="label">性别</view>
  37. <view class="radio" @tap="fetch.sex = 1">
  38. <image :src="fetch.sex == 1 ? '/static/images/common/round-black-selected.png' : '/static/images/common/gouxuankuang.png'"></image>
  39. <view>男</view>
  40. </view>
  41. <view class="radio" @tap="fetch.sex = 2">
  42. <image :src="fetch.sex == 2 ? '/static/images/common/round-black-selected.png' : '/static/images/common/gouxuankuang.png'"></image>
  43. <view>女</view>
  44. </view>
  45. <view class="radio" @tap="fetch.sex = 3">
  46. <image :src="fetch.sex == 3 ? '/static/images/common/round-black-selected.png' : '/static/images/common/gouxuankuang.png'"></image>
  47. <view>不显示</view>
  48. </view>
  49. </view>
  50. </list-cell>
  51. <list-cell line-right padding="30rpx" last>
  52. <view class="form-item">
  53. <view class="label">生日</view>
  54. <picker class="flex-fill" mode="date" :value="fetch.birthday" @change="handleBirthdayChange">
  55. <view v-if="fetch.birthday">{{ fetch.birthday }}</view>
  56. <view v-if="!fetch.birthday">请选择生日</view>
  57. </picker>
  58. </view>
  59. </list-cell>
  60. </view>
  61. <view class="save-btn">
  62. <wButton
  63. class="wbutton"
  64. text="修改资料"
  65. :rotate="isRotate"
  66. @click.native="update()"
  67. ></wButton>
  68. </view>
  69. <modal :show="telphoneModalVisible" custom padding="40rpx 30rpx">
  70. <view class="telphone-modal">
  71. <view class="header">
  72. <view>温馨提示</view>
  73. <image src="/static/images/common/closex.png" class="close-icon" @tap="closeTelphoneModal"></image>
  74. </view>
  75. <view class="tips">
  76. 请在绑定前确定新手机号未绑定合小记。
  77. </view>
  78. <view class="telphone-form">
  79. <list-cell padding="30rpx 0">
  80. <view class="telphone-input">
  81. <view class="prefix">+86</view>
  82. <input type="text" v-model="telphoneForm.telphone" placeholder="请填写有效手机号码" placeholder-class="font-size-base text-color-assist"/>
  83. </view>
  84. </list-cell>
  85. <list-cell padding="30rpx 0">
  86. <view class="verfiycode-input">
  87. <input type="text" v-model="telphoneForm.verifyCode" placeholder="6位数字验证码" placeholder-class="font-size-base text-color-assist">
  88. <view class="countdown" :class="{'text-color-assist': !countdown, 'text-color-base': countdown}" @tap="getVerifyCode">
  89. {{ !countdown ? '获取验证码' : countdown + '秒可获取' }}
  90. </view>
  91. </view>
  92. </list-cell>
  93. </view>
  94. <view class="footer">
  95. <button type="primary" @tap="closeTelphoneModal">确认</button>
  96. </view>
  97. </view>
  98. </modal>
  99. </view>
  100. </template>
  101. <script>
  102. import wInput from '@/lib/watch-login/watch-input.vue' //input
  103. import wButton from '@/lib/watch-login/watch-button.vue' //button
  104. import avatar from "@/lib/yq-avatar/yq-avatar.vue";
  105. import listCell from '@/lib/list-cell/list-cell.vue'
  106. import modal from '@/lib/modal/modal.vue'
  107. export default {
  108. components: {
  109. listCell,
  110. modal,
  111. wInput,
  112. wButton,
  113. avatar
  114. },
  115. data() {
  116. return {
  117. fetch : {
  118. name : '',
  119. avatar : '',
  120. sex : 3,
  121. },
  122. isRotate: false, //是否加载旋转
  123. openAvatar : false,
  124. telphoneModalVisible: false,
  125. telphoneForm: {
  126. telphone: '',
  127. verifyCode: ''
  128. },
  129. countdown: 0
  130. }
  131. },
  132. // 重新加载
  133. onPullDownRefresh: function() {
  134. this.getData();
  135. },
  136. onLoad() {
  137. this.Dever.checkLogin();
  138. this.getData();
  139. },
  140. methods: {
  141. getData : function() {
  142. this.Dever.get(this, 'app/user/?l=api.getBaseUser');
  143. },
  144. bind_weixin : function() {
  145. var self = this;
  146. this.Dever.confirm('即将开始微信授权,授权后您的微信信息将覆盖现有个人信息,但不会影响您已设置好的某个合小记中的个人信息。', function() {
  147. if (self.Dever.source == 'h5') {
  148. var host = self.Dever.api_host + 'package/oauth/?l=request.auth&account=1&system=1&system_source=' + self.Dever.source_id + '&signature=' + self.Dever.getToken();
  149. self.Dever.location(host, 'go');
  150. } else if (self.Dever.source == 'wx_applet') {
  151. uni.authorize({
  152. scope: 'scope.userInfo',
  153. success() {
  154. uni.login({
  155. provider: 'weixin',
  156. success: function (loginRes) {
  157. console.log(loginRes.authResult);
  158. // 获取用户信息
  159. uni.getUserInfo({
  160. provider: 'weixin',
  161. lang : 'zh_CN',
  162. success: function (infoRes) {
  163. console.log('用户昵称为:' + infoRes.userInfo.nickName);
  164. }
  165. });
  166. }
  167. });
  168. }
  169. })
  170. } else {
  171. self.Dever.alert('暂时不支持app登录');
  172. }
  173. });
  174. },
  175. index : function() {
  176. this.Dever.location('index/index');
  177. },
  178. tixian : function() {
  179. this.Dever.alert('敬请期待');
  180. },
  181. update : function() {
  182. if(this.isRotate){
  183. //判断是否加载中,避免重复点击请求
  184. return false;
  185. }
  186. if (!this.fetch.name) {
  187. this.Dever.alert('昵称不能为空');
  188. return false;
  189. }
  190. this.isRotate = true;
  191. var self = this;
  192. this.Dever.post('package/passport/?l=app.update', {noloading:1, username: this.fetch.name, info: this.fetch.info, gender: this.fetch.sex, title:this.fetch.title, birthday:this.fetch.birthday}, function(t) {
  193. self.isRotate = false;
  194. self.Dever.alert('已保存资料,仅影响未修改过信息的合小记');
  195. }, function(t) {
  196. self.Dever.alert(t.msg);
  197. self.isRotate = false;
  198. });
  199. },
  200. avatarUpload : function(e) {
  201. var self = this;
  202. this.openAvatar = false;
  203. this.Dever.uploadFile(e.path, 'avatar', 1, function(type, file) {
  204. self.fetch.avatar = file;
  205. self.Dever.post('package/passport/?l=app.update', {avatar:file, noloading:1});
  206. });
  207. },
  208. avatarSet : function(index) {
  209. this.openAvatar = true;
  210. this.$refs.avatar.fChooseImg(index,{
  211. selWidth: "300rpx", selHeight: "300rpx",
  212. expWidth: '260rpx', expHeight: '260rpx',
  213. avatarSrc : this.fetch.avatar,
  214. bgImage : this.fetch.avatar,
  215. noTab : true,
  216. });
  217. },
  218. handleBirthdayChange({target: {value}}) {
  219. this.fetch.birthday = value
  220. },
  221. showTelphoneModal() {
  222. this.telphoneModalVisible = true
  223. },
  224. closeTelphoneModal() {
  225. this.telphoneModalVisible = false
  226. this.telphoneForm = this.$options.data().telphoneForm
  227. },
  228. getVerifyCode() {
  229. if(this.countdown) return
  230. if(!this.telphoneForm.telphone) {
  231. uni.showToast({
  232. title: '请填写手机号码',
  233. icon: 'none'
  234. })
  235. return
  236. }
  237. this.countdown = 60
  238. let interval = setInterval(() => {
  239. if(!this.countdown) {
  240. clearInterval(interval)
  241. return
  242. }
  243. this.countdown -= 1
  244. }, 1000)
  245. }
  246. }
  247. }
  248. </script>
  249. <style lang="scss" scoped>
  250. .brand {
  251. background-color: $bg-color-white;
  252. display: flex;
  253. flex-direction: column;
  254. align-items: center;
  255. justify-content: center;
  256. padding: 40rpx 0;
  257. margin-bottom: 20rpx;
  258. .avatar {
  259. width: 200rpx;
  260. height: 200rpx;
  261. border-radius: 100%;
  262. margin-bottom: 30rpx;
  263. }
  264. .username {
  265. color: $font-size-medium;
  266. font-weight: bold;
  267. }
  268. }
  269. .user-form {
  270. .form-item {
  271. width: 100%;
  272. display: flex;
  273. align-items: center;
  274. .label {
  275. width: 160rpx;
  276. }
  277. input {
  278. flex: 1;
  279. }
  280. .radio {
  281. display: flex;
  282. margin-right: 50rpx;
  283. image {
  284. width: 40rpx;
  285. height: 40rpx;
  286. margin-right: 20rpx;
  287. }
  288. }
  289. }
  290. }
  291. .save-btn {
  292. padding: 0 30rpx;
  293. margin-top: 60rpx;
  294. button {
  295. width: 100%;
  296. font-size: $font-size-extra-lg;
  297. }
  298. }
  299. .telphone-modal {
  300. .header {
  301. display: flex;
  302. align-items: center;
  303. justify-content: center;
  304. position: relative;
  305. font-size: $font-size-extra-lg;
  306. font-weight: bold;
  307. margin-bottom: 30rpx;
  308. .close-icon {
  309. width: 60rpx;
  310. height: 60rpx;
  311. position: absolute;
  312. right: 0;
  313. }
  314. }
  315. .tips {
  316. color: $text-color-grey;
  317. line-height: 1.2rem;
  318. margin-bottom: 50rpx;
  319. }
  320. .telphone-form {
  321. font-size: $font-size-base;
  322. .telphone-input {
  323. width: 100%;
  324. display: flex;
  325. align-items: center;
  326. .prefix {
  327. color: $color-primary;
  328. display: flex;
  329. align-items: center;
  330. padding-right: 20rpx;
  331. position: relative;
  332. margin-right: 10rpx;
  333. &::after {
  334. content: " ";
  335. position: absolute;
  336. width: 4rpx;
  337. background-color: $border-color;
  338. }
  339. }
  340. input {
  341. flex: 1;
  342. }
  343. }
  344. .verfiycode-input {
  345. width: 100%;
  346. display: flex;
  347. align-items: center;
  348. justify-content: space-between;
  349. .countdown {
  350. font-size: $font-size-base;
  351. }
  352. }
  353. }
  354. .footer {
  355. margin-top: 30rpx;
  356. button {
  357. font-size: $font-size-lg;
  358. }
  359. }
  360. }
  361. </style>