index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <view class="me-content" :style="{'--status-bar-': statusBarHeight}">
  3. <view class="me-content-info">
  4. <!-- 头部主要内容 开始 -->
  5. <view class="me-content-header">
  6. <customNavbar
  7. title="我的"
  8. bgColor="#fff"
  9. :is-left="false"
  10. :contentStyle="{color: '#000'}"
  11. ></customNavbar>
  12. </view>
  13. <!-- 头部主要内容 结束 -->
  14. <!-- userInfo内容 开始 -->
  15. <view class="me-content-userinfo">
  16. <view class="me-userinfo-info">
  17. <view><text>分销商名称:</text><text>{{ userInfo && userInfo.name }}</text></view>
  18. <view><text>负责人:</text><text>{{ userInfo && userInfo.contact }}</text></view>
  19. </view>
  20. </view>
  21. <!-- userInfo内容 结束 -->
  22. <!-- tool内容 开始 -->
  23. <view class="me-content-tool">
  24. <view
  25. class="me-tool-item"
  26. v-for="(item,index) in tool"
  27. :key="index"
  28. @click="navigateToFun(item)"
  29. >
  30. <image
  31. class="me-tool-item-icon"
  32. :src="item.icon"></image>
  33. <text>{{ item.title }}</text>
  34. <view><u-icon name="arrow-right"></u-icon></view>
  35. </view>
  36. </view>
  37. <!-- tool内容 结束 -->
  38. <!-- 退出登录 -->
  39. <view class="me-content-loginout">
  40. <u-button
  41. class="login-info-submit-but"
  42. @click="submit()"
  43. :loading="loading"
  44. loadingText="退出中..."
  45. >退出登录</u-button>
  46. </view>
  47. </view>
  48. <!-- 我的分享码 -->
  49. <customPromotionCode ref="customPromotionCode" />
  50. </view>
  51. </template>
  52. <script>
  53. import { navigateTo } from "@/utils/util.js"
  54. export default {
  55. data() {
  56. return {
  57. title: '这是我的',
  58. loading: false,
  59. statusBarHeight: 0, // 状态栏安全距离
  60. tool: [ // 我的工具
  61. { title: "邀请统计",icon: this.$commonConfig.staticUrl + 'me/yijian2.png', url: '/pages/invitationStatistics/index' },
  62. { title: "余额提现",icon: this.$commonConfig.staticUrl + 'me/beifeng.png', url: '/pages/balance/index' },
  63. { title: "我的推广码",icon: this.$commonConfig.staticUrl + 'me/yijian1.png', url: '' },
  64. // { title: "提现记录",icon: this.$commonConfig.staticUrl + 'me/beifeng.png', url: '/pages/cashList/index' },
  65. ],
  66. userInfo: {}
  67. }
  68. },
  69. mounted() {
  70. console.log('wpsdfsfasdfads')
  71. this.statusBarHeight = getApp().globalData.statusBarHeight
  72. this.getUserInfo()
  73. // #ifdef H5
  74. //window.addEventListener('popstate', this.browserBack)
  75. // #endif
  76. },
  77. destroyed() {
  78. console.log("dsfadsfsdfasdf")
  79. //window.removeEventListener("popstate", this.browserBack);
  80. },
  81. methods: {
  82. /**
  83. * @author ygh
  84. * @data 2023-12-20
  85. */
  86. navigateToFun(item){
  87. if(item.url) {
  88. navigateTo(item.url)
  89. }else {
  90. this.getRetailQrcode()
  91. }
  92. },
  93. /**
  94. * 获取用户信息
  95. */
  96. async getUserInfo() {
  97. try{
  98. let res = await this.$u.api.getInfo({
  99. noSign: 1,
  100. userid: this.vuex_user_info.userId
  101. })
  102. if(res && res.code ===200) {
  103. this.userInfo = res.data
  104. }
  105. }catch(e){
  106. //TODO handle the exception
  107. console.error("e===",e)
  108. }
  109. },
  110. /**
  111. * 我的推广码
  112. */
  113. async getRetailQrcode(){
  114. try{
  115. let res = await this.$u.api.getRetailQrcode({
  116. noSign: 1,
  117. userid: this.vuex_user_info.userId
  118. })
  119. if(res && res.code ===200) {
  120. this.$refs.customPromotionCode.initData(res.data)
  121. // #ifdef H5
  122. //window.history.pushState(null, null, document.URL)
  123. // #endif
  124. }
  125. }catch(e){
  126. //TODO handle the exception
  127. console.error("e===",e)
  128. }
  129. },
  130. /**
  131. *
  132. * 提交登录
  133. *
  134. */
  135. submit() {
  136. // 在这里写弹框
  137. uni.showModal({
  138. title: '提示',
  139. content: '确定退出登录吗?',
  140. cancelText: '取消',
  141. confirmText: '确定',
  142. success: (res) => {
  143. if(res.confirm){
  144. this.loginOut()
  145. }
  146. }
  147. });
  148. },
  149. async loginOut() {
  150. // console.log("vuex_user_info===",this.vuex_user_info)
  151. // return
  152. // if(!this.vuex_user_info.accessToken) {
  153. // this.$u.vuex('vuex_user_info', {});
  154. // uni.reLaunch({
  155. // url: "/pages/login/index"
  156. // })
  157. // return
  158. // }
  159. this.loading = true
  160. try{
  161. let res = await this.$u.api.loginOut({})
  162. this.loading = false
  163. if(res && res.code ===200) {
  164. uni.setStorageSync('lifeData',{}); // 清除缓存
  165. this.$u.vuex('vuex_user_info', {});
  166. uni.reLaunch({
  167. url: "/pages/login/index"
  168. })
  169. } else {
  170. // uni.showToast({
  171. // icon: "none",
  172. // title: res.msg
  173. // })
  174. uni.setStorageSync('lifeData',{}); // 清除缓存
  175. this.$u.vuex('vuex_user_info', {});
  176. uni.reLaunch({
  177. url: "/pages/login/index"
  178. })
  179. }
  180. this.loading = false
  181. }catch(e){
  182. //TODO handle the exception
  183. console.error("e===",e)
  184. // uni.showToast({
  185. // icon: "none",
  186. // title: "退出失败"
  187. // })
  188. uni.setStorageSync('lifeData',{}); // 清除缓存
  189. this.$u.vuex('vuex_user_info', {});
  190. uni.reLaunch({
  191. url: "/pages/login/index"
  192. })
  193. this.loading = false
  194. }
  195. },
  196. browserBack() {
  197. // 在这里写弹框
  198. uni.showModal({
  199. title: '提示',
  200. content: '返回后此页面的操作将不作保留!',
  201. cancelText: '确定返回',
  202. confirmText: '留在此页',
  203. success: (res) => {
  204. if (res.confirm) {
  205. // 用户选择留在此页,不进行任何操作
  206. } else if (res.cancel) {
  207. window.history.back(); // 使用window.history.back()返回上一页
  208. }
  209. }
  210. });
  211. //window.history.replaceState(null, null, document.URL); // 保留此行代码
  212. },
  213. }
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. .me-content {
  218. display: flex;
  219. flex-direction: column;
  220. align-items: center;
  221. justify-content: center;
  222. --header-h: 90rpx;
  223. .me-content-info {
  224. width: 100%;
  225. box-sizing: border-box;
  226. }
  227. }
  228. /** 头部主要内容 开始 */
  229. .me-content-header {
  230. width: 100%;
  231. height: var(--header-h);
  232. box-sizing: border-box;
  233. ::v-deep .u-search {
  234. padding: 0 30rpx !important;
  235. }
  236. ::v-deep .u-search__action {
  237. color: #fff !important;
  238. }
  239. }
  240. /** 头部主要内容 结束 **/
  241. /** userInfo内容 开始 */
  242. .me-content-userinfo {
  243. width: 100%;
  244. padding: 24rpx;
  245. box-sizing: border-box;
  246. .me-userinfo-info {
  247. width: 100%;
  248. height: 200rpx;
  249. box-sizing: border-box;
  250. background: linear-gradient(to bottom, rgba(238, 12, 12, 1) 0%, rgba(243, 157, 159, 1) 100%);
  251. border-radius: 20rpx;
  252. box-shadow: 0rpx 0 20rpx 2rpx rgba(205, 205, 205, 0.50);
  253. display: flex;
  254. flex-direction: column;
  255. align-items: flex-start;
  256. justify-content: center;
  257. color: #fff;
  258. font-size: 28rpx;
  259. font-family: SourceHanSansCN, SourceHanSansCN;
  260. padding: 0 50rpx;
  261. >view:nth-child(1) {
  262. display: flex;
  263. font-weight: 600;
  264. width: 100%;
  265. text:nth-child(1) {
  266. width: 168rpx;
  267. flex-shrink: 0;
  268. }
  269. text:nth-child(2) {
  270. width: calc( 100% - 168rpx );
  271. overflow: hidden;
  272. display: -webkit-box;
  273. -webkit-line-clamp: 2; /* 设置最大显示行数 */
  274. -webkit-box-orient: vertical;
  275. text-overflow: ellipsis;
  276. }
  277. }
  278. >view:nth-child(2) {
  279. width: 100%;
  280. display: flex;
  281. margin-top: 20rpx;
  282. text:nth-child(1) {
  283. width: 112rpx;
  284. flex-shrink: 0;
  285. }
  286. text:nth-child(2) {
  287. width: calc( 100% - 112rpx );
  288. }
  289. }
  290. }
  291. }
  292. /** userInfo内容 结束 **/
  293. /** tool内容 开始 */
  294. .me-content-tool {
  295. width: 100%;
  296. box-sizing: border-box;
  297. padding: 30rpx 30rpx 0;
  298. .me-tool-item {
  299. width: 100%;
  300. background: #FBFBFB;
  301. border-radius: 20rpx;
  302. box-sizing: border-box;
  303. display: flex;
  304. align-items: center;
  305. justify-content: space-between;
  306. color: rgba(54, 54, 54, 1);
  307. font-size: 28rpx;
  308. padding: 12rpx 10rpx;
  309. margin-bottom: 20rpx;
  310. .me-tool-item-icon {
  311. width: 54rpx;
  312. height: 56rpx;
  313. flex-shrink: 0;
  314. }
  315. >text {
  316. width: 100%;
  317. padding-left: 20rpx;
  318. box-sizing: border-box;
  319. }
  320. }
  321. }
  322. /** tool内容 结束 */
  323. /** */
  324. .me-content-loginout {
  325. width: 100%;
  326. padding: 50rpx 50rpx 0;
  327. box-sizing: border-box;
  328. .login-info-submit-but {
  329. display: flex;
  330. justify-content: center;
  331. align-items: center;
  332. border-radius: 40rpx;
  333. width: 100% !important;
  334. height: 80rpx !important;
  335. background-color: var(--gd-bgm-color);
  336. color: #fff;
  337. }
  338. }
  339. </style>