index.vue 9.6 KB

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