index.vue 8.6 KB

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