index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <script>
  2. import { getUserInfo, getLogout } from '@/api/user.js';
  3. import { toLogin } from '@/libs/login.js';
  4. import { mapGetters, mapMutations } from 'vuex';
  5. import colors from '@/mixins/color.js';
  6. import tuiModal from '@/components/tui-modal/index.vue';
  7. import NavBar from '@/components/NavBar.vue';
  8. export default {
  9. computed: mapGetters(['isLogin']),
  10. data() {
  11. return {
  12. userInfo: {},
  13. isShowAuth: false,
  14. autoplay: this.$store.state.app.autoplay,
  15. loginType: 'h5',
  16. showModal: false
  17. };
  18. },
  19. mixins: [colors],
  20. components: { tuiModal, NavBar },
  21. onShow() {
  22. if (this.isLogin) {
  23. this.getUserInfo();
  24. } else {
  25. toLogin();
  26. }
  27. },
  28. methods: {
  29. ...mapMutations(['SET_AUTOPLAY']),
  30. /**
  31. * 小程序设置
  32. */
  33. Setting() {
  34. uni.openSetting({
  35. success: function (res) {}
  36. });
  37. },
  38. getUserInfo() {
  39. let that = this;
  40. getUserInfo().then((res) => {
  41. that.userInfo = res.data;
  42. });
  43. },
  44. autoplayChange(event) {
  45. this.SET_AUTOPLAY(event.detail.value);
  46. },
  47. handleClick(e) {
  48. let index = e.index;
  49. if (index == 1) {
  50. getLogout()
  51. .then((res) => {
  52. this.showModal = false;
  53. this.$store.commit('LOGOUT');
  54. uni.switchTab({
  55. url: '/pages/index/index'
  56. });
  57. })
  58. .catch((err) => {});
  59. } else {
  60. this.showModal = false;
  61. }
  62. },
  63. outLogin() {
  64. this.showModal = true;
  65. }
  66. }
  67. };
  68. </script>
  69. <template>
  70. <!-- 设置 -->
  71. <view :style="colorStyle">
  72. <!-- #ifdef MP -->
  73. <NavBar showBack bagColor="#f5f5f5" titleText="设置"></NavBar>
  74. <!-- #endif -->
  75. <view class="userSet">
  76. <navigator url="/pages/users/user_info/index" hover-class="none" class="userInfo acea-row row-between-wrapper rd-24rpx mx-20">
  77. <view class="picTxt acea-row row-middle">
  78. <view class="pictrue">
  79. <image :src="userInfo.avatar"></image>
  80. </view>
  81. <view class="text">
  82. <view class="name line1">{{ userInfo.nickname }}</view>
  83. <view class="info">ID:{{ userInfo.uid }}</view>
  84. </view>
  85. </view>
  86. <view class="iconfont icon-ic_rightarrow"></view>
  87. </navigator>
  88. <view class="list rd-24rpx mx-20">
  89. <navigator url="/pages/users/user_address_list/index" hover-class="none" class="item acea-row row-between-wrapper">
  90. <view>地址管理</view>
  91. <view class="grab">
  92. <text class="iconfont icon-ic_rightarrow"></text>
  93. </view>
  94. </navigator>
  95. <navigator url="/pages/users/user_invoice_list/index" hover-class="none" class="item acea-row row-between-wrapper">
  96. <view>发票管理</view>
  97. <view class="grab">
  98. <text class="iconfont icon-ic_rightarrow"></text>
  99. </view>
  100. </navigator>
  101. </view>
  102. <view class="list rd-24rpx mx-20">
  103. <view class="item acea-row row-between-wrapper">
  104. <view>移动网络下视频自动播放</view>
  105. <switch :checked="autoplay" @change="autoplayChange" />
  106. </view>
  107. <!-- #ifdef MP -->
  108. <view class="item acea-row row-between-wrapper">
  109. <view>权限设置</view>
  110. <view class="input grab" @click="Setting">
  111. <text class="iconfont icon-ic_rightarrow"></text>
  112. </view>
  113. </view>
  114. <!-- #endif -->
  115. <navigator url="/pages/users/user_agreement_list/index" hover-class="none" class="item acea-row row-between-wrapper">
  116. <view>政策协议</view>
  117. <view class="input grab">
  118. <text class="iconfont icon-ic_rightarrow"></text>
  119. </view>
  120. </navigator>
  121. </view>
  122. <!-- #ifdef H5 -->
  123. <view class="log-out list rd-24rpx mx-20 acea-row row-center-wrapper" @click="outLogin" v-if="!this.$wechat.isWeixin()">退出登录</view>
  124. <!-- #endif -->
  125. <!-- #ifdef APP-PLUS -->
  126. <view class="log-out list rd-24rpx mx-20 acea-row row-center-wrapper" @click="outLogin">退出登录</view>
  127. <!-- #endif -->
  128. <!-- 确认框 -->
  129. <tuiModal :show="showModal" title="提示" content="确认退出登录?" :maskClosable="false" @click="handleClick"></tuiModal>
  130. </view>
  131. </view>
  132. </template>
  133. <style lang="scss">
  134. .userSet {
  135. .userInfo {
  136. margin-top: 20rpx;
  137. background-color: #fff;
  138. padding: 32rpx 16rpx 32rpx 32rpx;
  139. .iconfont {
  140. font-size: 30rpx;
  141. color: #999;
  142. }
  143. .picTxt {
  144. .text {
  145. margin-left: 30rpx;
  146. font-weight: 400;
  147. .name {
  148. font-size: 32rpx;
  149. color: #333;
  150. }
  151. .info {
  152. font-size: 24rpx;
  153. color: #999;
  154. margin-top: 5rpx;
  155. }
  156. }
  157. .pictrue {
  158. width: 120rpx;
  159. height: 120rpx;
  160. image {
  161. width: 100%;
  162. height: 100%;
  163. border: 1px solid #eee;
  164. border-radius: 50%;
  165. }
  166. }
  167. }
  168. }
  169. .list {
  170. background-color: #fff;
  171. margin-top: 20rpx;
  172. .item {
  173. padding: 32rpx 20rpx 24rpx 24rpx;
  174. font-size: 30rpx;
  175. color: #333;
  176. .grab {
  177. color: #ccc;
  178. .iconfont {
  179. font-size: 30rpx;
  180. color: #999;
  181. margin-left: 6rpx;
  182. }
  183. }
  184. /deep/.uni-switch-input {
  185. width: 84rpx;
  186. height: 48rpx;
  187. margin: -8rpx 0;
  188. &::before {
  189. width: 80rpx;
  190. height: 44rpx;
  191. }
  192. &::after {
  193. width: 44rpx;
  194. height: 44rpx;
  195. }
  196. }
  197. }
  198. }
  199. .log-out {
  200. font-size: 30rpx;
  201. text-align: center;
  202. color: #333333;
  203. width: 710rpx;
  204. height: 98rpx;
  205. border-radius: 24rpx;
  206. margin: 30rpx auto 0 auto;
  207. }
  208. }
  209. </style>