userInfo.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view class="tui-userinfo-box">
  3. <button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  4. <tui-list-cell padding="0" :arrow="true">
  5. <view class="tui-list-cell">
  6. <view>头像</view>
  7. <image :src="memberinfo.userpic" class="tui-avatar"></image>
  8. </view>
  9. </tui-list-cell>
  10. </button>
  11. <tui-list-cell padding="0" :arrow="true" @click="nickname">
  12. <view class="tui-list-cell">
  13. <view>昵称</view>
  14. <view class="tui-content">{{memberinfo.nickname}}</view>
  15. </view>
  16. </tui-list-cell>
  17. <tui-list-cell padding="0" :arrow="true" @click="changeSex">
  18. <view class="tui-list-cell">
  19. <view>性别</view>
  20. <view class="tui-content">{{sex}}</view>
  21. </view>
  22. </tui-list-cell>
  23. <!--<picker mode="date" @change="changeDate">
  24. <tui-list-cell padding="0" :arrow="true" unlined>
  25. <view class="tui-list-cell">
  26. <view>出生日期</view>
  27. <view class="tui-content">{{date}}</view>
  28. </view>
  29. </tui-list-cell>
  30. </picker>-->
  31. <view v-if="gotopage" class="tui-butt">
  32. <button @click="ongotopage" class="btn86" :style="'background:'+ pagestyleconfig.appstylecolor">下一步</button>
  33. </view>
  34. <!-- #ifdef H5 -->
  35. <tui-modal :show="wxmpautomodal" @cancel="wxmpautomodalcancel" :custom="true" fadeIn>
  36. <view class="tui-modal-custom">
  37. <view class="tui-prompt-title">你可以自动获取微信头像昵称</view>
  38. <view class="tui-modal__btn">
  39. <view class="tui-box">
  40. <button :style="'background:'+ pagestyleconfig.appstylecolor" class="tui-btn-danger" @click="getmpuserinfo">自动获取微信头像昵称</button>
  41. </view>
  42. <view class="tui-box">
  43. <tui-button type="white" shape="circle" height="80rpx" :size="26"
  44. @click="wxmpautomodalcancel">手动填写</tui-button>
  45. </view>
  46. </view>
  47. </view>
  48. </tui-modal>
  49. <!-- #endif -->
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. sex: '男',
  57. date: '请选择',
  58. pagestyleconfig: [],
  59. memberinfo: [],
  60. gotopage: '',
  61. wxmpautomodal: false,
  62. }
  63. },
  64. onLoad(e) {
  65. var _this = this;
  66. if (e.gotopage) {
  67. this.gotopage = e.gotopage;
  68. uni.setStorageSync("gotopage", this.gotopage);
  69. }else{
  70. this.gotopage = uni.getStorageSync('gotopage')
  71. }
  72. _this.$request.post('config', {
  73. mo: 'pagestyle'
  74. }).then(res => {
  75. if (res.errno == 0) {
  76. _this.pagestyleconfig = res.data
  77. }
  78. });
  79. },
  80. onShow: function() {
  81. let _this = this;
  82. var isWeixin = 0;
  83. // #ifdef H5
  84. var ua = navigator.userAgent.toLowerCase();
  85. isWeixin = ua.indexOf('micromessenger') != -1;
  86. // #endif
  87. _this.$util.getUserInfo(function(userInfo) {
  88. //Console.log("adfs");
  89. _this.$request.get('member.detail', {
  90. samkey: (new Date()).valueOf()
  91. }).then(res => {
  92. if (res.errno == 0) {
  93. _this.memberinfo = res.data;
  94. _this.sex = res.data.sex;
  95. if (isWeixin) {
  96. if (_this.memberinfo.nickname == '微信用户' || _this.memberinfo.nickname ==
  97. '匿名用户') {
  98. _this.wxmpautomodal = true
  99. }
  100. }
  101. }
  102. });
  103. })
  104. },
  105. /*
  106. onUnload: function() {
  107. uni.navigateTo({
  108. url: '/pagesA/my/userInfo/index'
  109. });
  110. },
  111. */
  112. methods: {
  113. getmpuserinfo: function() {
  114. let _this = this;
  115. _this.$util.getmpuserinfo().then(res => {
  116. uni.navigateTo({
  117. url: '/pagesA/my/userInfo/index'
  118. });
  119. });
  120. },
  121. wxmpautomodalcancel() {
  122. this.wxmpautomodal = false
  123. },
  124. ongotopage() {
  125. console.log(this.gotopage);
  126. this.sam.navigateTo(this.gotopage);
  127. },
  128. onChooseAvatar(e) {
  129. this.tui.href('/pagesA/my/cropper/cropper?src=' + e.detail.avatarUrl);
  130. console.log(e);
  131. },
  132. onChooseAvatar2() {
  133. uni.chooseImage({
  134. count: 1,
  135. sizeType: ['original', 'compressed'],
  136. sourceType: ['album', 'camera'],
  137. success: res => {
  138. console.log(res);
  139. const tempFilePaths = res.tempFilePaths[0];
  140. this.tui.href('/pagesA/my/cropper/cropper?src=' + tempFilePaths);
  141. }
  142. });
  143. },
  144. nickname() {
  145. this.tui.href("/pagesA/my/nickname/nickname")
  146. },
  147. changeSex() {
  148. let _this = this
  149. uni.showActionSheet({
  150. itemList: ['男', '女'],
  151. success(e) {
  152. _this.sex = ['男', '女'][e.tapIndex];
  153. _this.$request.post('member.update', {
  154. sex: _this.sex
  155. }).then(res => {
  156. if (res.errno == 0) {
  157. }
  158. });
  159. }
  160. })
  161. },
  162. changeDate(e) {
  163. console.log(e)
  164. this.date = e.detail.value
  165. }
  166. },
  167. /**
  168. * 页面相关事件处理函数--监听用户下拉动作
  169. */
  170. onPullDownRefresh: function() {
  171. setTimeout(() => {
  172. uni.stopPullDownRefresh()
  173. }, 200);
  174. },
  175. }
  176. </script>
  177. <style>
  178. .tui-userinfo-box {
  179. margin: 20rpx 0;
  180. color: #333;
  181. }
  182. .avatar-wrapper {
  183. padding-left: 0px;
  184. padding-right: 0px;
  185. box-sizing: border-box;
  186. border-radius: 0px;
  187. }
  188. .tui-list-cell {
  189. width: 100%;
  190. display: flex;
  191. align-items: center;
  192. justify-content: space-between;
  193. padding: 24rpx 60rpx 24rpx 30rpx;
  194. box-sizing: border-box;
  195. font-size: 30rpx;
  196. }
  197. .tui-pr30 {
  198. padding-right: 30rpx;
  199. }
  200. .tui-avatar {
  201. width: 100rpx;
  202. height: 100rpx;
  203. border-radius: 50%;
  204. display: block;
  205. }
  206. .tui-content {
  207. font-size: 26rpx;
  208. color: #666;
  209. }
  210. .tui-butt {
  211. padding: 100rpx 24rpx;
  212. }
  213. .tui-modal-custom {
  214. padding-top: 60rpx;
  215. padding-bottom: 50rpx;
  216. text-align: center;
  217. }
  218. .tui-prompt-title {
  219. padding-bottom: 20rpx;
  220. font-size: 34rpx;
  221. }
  222. .tui-modal__btn {
  223. align-items: center;
  224. justify-content: space-between;
  225. }
  226. .tui-box {
  227. padding: 15rpx 20rpx;
  228. box-sizing: border-box;
  229. }
  230. .tui-btn-danger {
  231. height: 80rpx;
  232. line-height: 80rpx;
  233. border-radius: 98rpx;
  234. color: #fff;
  235. }
  236. .btn86{
  237. height: 86rpx;
  238. line-height: 86rpx;
  239. border-radius: 98rpx;
  240. color: #fff;
  241. }
  242. </style>