index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <!-- 设置 -->
  3. <view class="userSet" :style="colorStyle">
  4. <navigator url="/pages/users/user_info/index" hover-class="none" class="userInfo acea-row row-between-wrapper">
  5. <view class="picTxt acea-row row-middle">
  6. <view class="pictrue">
  7. <image :src="userInfo.avatar"></image>
  8. </view>
  9. <view class="text">
  10. <view class="name line1">{{userInfo.nickname}}</view>
  11. <view class="info">ID:{{userInfo.uid}}</view>
  12. </view>
  13. </view>
  14. <view class="iconfont icon-xiangyou"></view>
  15. </navigator>
  16. <view class="list">
  17. <!-- #ifdef H5 -->
  18. <view class="item acea-row row-between-wrapper" v-if="userInfo.phone && !this.$wechat.isWeixin()">
  19. <view>密码</view>
  20. <navigator url="/pages/users/user_pwd_edit/index" hover-class="none" class="input grab">
  21. 点击修改密码<text class="iconfont icon-xiangyou"></text>
  22. </navigator>
  23. </view>
  24. <!-- #endif -->
  25. <!-- #ifdef APP-PLUS -->
  26. <view class="item acea-row row-between-wrapper" v-if="userInfo.phone">
  27. <view>密码</view>
  28. <navigator url="/pages/users/user_pwd_edit/index" hover-class="none" class="grab">
  29. 点击修改密码<text class="iconfont icon-xiangyou"></text>
  30. </navigator>
  31. </view>
  32. <!-- #endif -->
  33. <view class="item acea-row row-between-wrapper" v-if="userInfo.phone">
  34. <view>更换手机号码</view>
  35. <navigator url="/pages/users/user_phone/index?type=1" hover-class="none" class="grab">
  36. 点击更换手机号码<text class="iconfont icon-xiangyou"></text>
  37. </navigator>
  38. </view>
  39. </view>
  40. <view class="list">
  41. <view class="item acea-row row-between-wrapper">
  42. <view>地址管理</view>
  43. <navigator url="/pages/users/user_address_list/index" hover-class="none" class="grab">
  44. 点击前往<text class="iconfont icon-xiangyou"></text>
  45. </navigator>
  46. </view>
  47. <view class="item acea-row row-between-wrapper">
  48. <view>发票管理</view>
  49. <navigator url="/pages/users/user_invoice_list/index" hover-class="none" class="grab">
  50. 点击前往<text class="iconfont icon-xiangyou"></text>
  51. </navigator>
  52. </view>
  53. </view>
  54. <view class="list">
  55. <!-- #ifndef APP-PLUS -->
  56. <view class="item acea-row row-between-wrapper">
  57. <view>移动网络下视频自动播放</view>
  58. <switch :checked="autoplay" @change="autoplayChange" />
  59. </view>
  60. <!-- #endif -->
  61. <!-- #ifdef MP -->
  62. <view class='item acea-row row-between-wrapper'>
  63. <view>权限设置</view>
  64. <view class="input grab" @click="Setting">
  65. 点击管理<text class="iconfont icon-xiangyou"></text>
  66. </view>
  67. </view>
  68. <!-- #endif -->
  69. <view class="item acea-row row-between-wrapper">
  70. <view>账号注销</view>
  71. <navigator url="/pages/users/user_cancellation/index" hover-class="none" class="input grab">
  72. 注销后无法恢复<text class="iconfont icon-xiangyou"></text>
  73. </navigator>
  74. </view>
  75. </view>
  76. <view class="logOut cartcolor acea-row row-center-wrapper" @click="outLogin">退出登录</view>
  77. <!-- #ifdef MP -->
  78. <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize>
  79. <!-- #endif -->
  80. </view>
  81. </template>
  82. <style lang="scss">
  83. .logOut {
  84. font-size: 32rpx;
  85. text-align: center;
  86. width: 690rpx;
  87. height: 90rpx;
  88. border-radius: 45rpx;
  89. margin: 30rpx auto 0 auto;
  90. }
  91. .cartcolor {
  92. color: #FFF;
  93. // border: 1px solid var(--view-theme);
  94. background-color:var(--view-theme) ;
  95. }
  96. .userSet {
  97. .userInfo {
  98. margin-top: 20rpx;
  99. background-color: #fff;
  100. padding: 0 30rpx;
  101. height: 144rpx;
  102. .iconfont {
  103. font-size: 30rpx;
  104. color: #868686;
  105. }
  106. .picTxt {
  107. .text {
  108. width: 524rpx;
  109. margin-left: 30rpx;
  110. font-weight: 400;
  111. .name {
  112. font-size: 32rpx;
  113. color: #333;
  114. }
  115. .info {
  116. font-size: 24rpx;
  117. color: #999;
  118. margin-top: 5rpx;
  119. }
  120. }
  121. .pictrue {
  122. width: 88rpx;
  123. height: 88rpx;
  124. image {
  125. width: 100%;
  126. height: 100%;
  127. border: 1px solid #eee;
  128. border-radius: 50%;
  129. }
  130. }
  131. }
  132. }
  133. .list{
  134. background-color: #fff;
  135. margin-top: 20rpx;
  136. .item{
  137. padding: 30rpx 30rpx 30rpx 0;
  138. border-bottom: 1rpx solid #f2f2f2;
  139. margin-left: 30rpx;
  140. font-size: 32rpx;
  141. color: #333;
  142. .grab{
  143. color: #ccc;
  144. .iconfont{
  145. font-size: 30rpx;
  146. color: #868686;
  147. margin-left: 6rpx;
  148. }
  149. }
  150. /deep/.uni-switch-input {
  151. width: 84rpx;
  152. height: 48rpx;
  153. margin: -8rpx 0;
  154. &::before {
  155. width: 80rpx;
  156. height: 44rpx;
  157. }
  158. &::after {
  159. width: 44rpx;
  160. height: 44rpx;
  161. }
  162. }
  163. }
  164. }
  165. }
  166. </style>
  167. <script>
  168. import {
  169. getUserInfo,
  170. getLogout
  171. } from '@/api/user.js';
  172. import {
  173. toLogin
  174. } from '@/libs/login.js';
  175. import {
  176. mapGetters,
  177. mapMutations
  178. } from "vuex";
  179. import colors from '@/mixins/color.js';
  180. export default {
  181. computed: mapGetters(['isLogin']),
  182. mixins: [colors],
  183. data() {
  184. return {
  185. loginType: 'h5', //app.globalData.loginType
  186. userInfo:{},
  187. isShowAuth: false,
  188. autoplay: this.$store.state.app.autoplay
  189. }
  190. },
  191. onLoad() {},
  192. onShow() {
  193. if (this.isLogin) {
  194. this.getUserInfo();
  195. } else {
  196. //#ifndef MP
  197. toLogin();
  198. //#endif
  199. //#ifdef MP
  200. this.isShowAuth = true;
  201. //#endif
  202. }
  203. },
  204. methods: {
  205. ...mapMutations(['SET_AUTOPLAY']),
  206. /**
  207. * 退出登录
  208. *
  209. */
  210. outLogin: function() {
  211. let that = this;
  212. if (that.loginType == 'h5') {
  213. uni.showModal({
  214. title: '提示',
  215. content: '确认退出登录?',
  216. success: function(res) {
  217. if (res.confirm) {
  218. getLogout()
  219. .then(res => {
  220. that.$store.commit("LOGOUT");
  221. uni.reLaunch({
  222. url: '/pages/index/index'
  223. })
  224. })
  225. .catch(err => {});
  226. } else if (res.cancel) {
  227. console.log('用户点击取消');
  228. }
  229. }
  230. });
  231. }
  232. },
  233. /**
  234. * 小程序设置
  235. */
  236. Setting: function() {
  237. uni.openSetting({
  238. success: function(res) {
  239. }
  240. });
  241. },
  242. onLoadFun(){
  243. this.getUserInfo();
  244. this.isShowAuth = false
  245. },
  246. // 授权关闭
  247. authColse: function(e) {
  248. this.isShowAuth = e
  249. },
  250. getUserInfo(){
  251. let that = this;
  252. getUserInfo().then(res => {
  253. that.userInfo = res.data;
  254. });
  255. },
  256. autoplayChange(event){
  257. this.SET_AUTOPLAY(event.detail.value);
  258. }
  259. }
  260. }
  261. </script>