index.vue 8.9 KB

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