index.vue 10 KB

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