index.vue 8.7 KB

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