index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <view class="content">
  3. <view class="selfInfo-box">
  4. <view>
  5. <button type="primary" @click.stop="goAuth" v-if="!isAuth" class="authUser">点击授权</button>
  6. </view>
  7. <view class="self-auth" v-if='isAuth'>
  8. <image :src="userHead" mode=""></image>
  9. <view style="margin-left: 3%;">
  10. <text>{{userName}}</text>
  11. <text style="font-size: 28rpx;" v-if="isAuthPhone">{{userPhone}} </text>
  12. <button type="primary" class="authPhone" open-type="getPhoneNumber" style="font-size: 12px;"
  13. @getphonenumber="getPhoneNumber" v-else>手机号码授权</button>
  14. </view>
  15. </view>
  16. <view class="self-content">
  17. <view>
  18. <text style="font-size: 36rpx;">{{userInfoObj.scorenumber || '0'}}</text>
  19. <text style="font-size: 28rpx;">我的积分</text>
  20. </view>
  21. <view>
  22. <text style="font-size: 36rpx;">{{userInfoObj.num || '0'}}<text style="font-size: 28rpx;">元</text></text>
  23. <text style="font-size: 28rpx;">已提现</text>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="function-box">
  28. <view class="function-content" @click="goRecommend">
  29. <image src="../../static/commend.png" style="width: 90rpx;" mode="aspectFit" ></image>
  30. <text>推荐分销品</text>
  31. </view>
  32. <view class="function-content" style="background: #33b5fc;" @click="goAward">
  33. <image src="../../static/award.svg" mode=""></image>
  34. <text>奖励记录</text>
  35. </view>
  36. <view class="function-content" style="background:#fcca2f;" @click="goCashOut">
  37. <image src="../../static/cashout.svg" mode=""></image>
  38. <text>提现记录</text>
  39. </view>
  40. </view>
  41. <view class="list-box">
  42. <view class="list-content" @click="applyPower">
  43. <text class="margin-left5">分销资格</text>
  44. <view class="apply-box">
  45. <text style="color: #999;" :style="{'margin-right':userStatus==='点击申请'? '0':'2px'}" decode="true">{{userStatus}}</text>
  46. <image src="../../static/arrow-right2.png" mode=""></image>
  47. </view>
  48. </view>
  49. <view class="list-content" @click="goTeamDetail">
  50. <text class="margin-left5">分销团队</text>
  51. <view class="apply-box">
  52. <text style="color: #999;visibility: hidden;">点击申请</text>
  53. <image src="../../static/arrow-right2.png" mode=""></image>
  54. </view>
  55. </view>
  56. <view class="list-content" style="border-bottom: none;" @click="goHelpPage">
  57. <text class="margin-left5">帮助中心</text>
  58. <view class="apply-box">
  59. <text style="color: #999;visibility: hidden;">点击申请</text>
  60. <image src="../../static/arrow-right2.png" mode=""></image>
  61. </view>
  62. </view>
  63. <button class="list-content change-phone" style="border-bottom: none;"
  64. open-type="getPhoneNumber" @getphonenumber="changePhoneNumber">
  65. <text class="margin-left5">更改手机号码</text>
  66. <view class="apply-box">
  67. <text style="color: #999;visibility: hidden;">点击申请</text>
  68. <image src="../../static/arrow-right2.png" mode=""></image>
  69. </view>
  70. </button>
  71. </view>
  72. <uni-popup ref="showtip" type="center" :mask-click="false" @change="change">
  73. <view class="uni-tip">
  74. <!-- <text class="uni-tip-title">警告</text> -->
  75. <text class="uni-tip-content">您的申请需要后台审核,确定后请耐心等待结果。</text>
  76. <view class="uni-tip-group-button">
  77. <text class="uni-tip-button" @click="cancel()">取消</text>
  78. <text class="uni-tip-button" @click="submitApply()">确定</text>
  79. </view>
  80. </view>
  81. </uni-popup>
  82. </view>
  83. </template>
  84. <script>
  85. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  86. var md5 = require('../../common/md5.js')
  87. export default {
  88. components: {
  89. uniPopup,
  90. },
  91. data() {
  92. return {
  93. title: 'selfCenter',
  94. userName:getApp().globalData.user_name,
  95. userHead:getApp().globalData.user_headUrl || '/static/logo.png',
  96. userPhone:getApp().globalData.user_phone || '156****3232',
  97. isAuth:getApp().globalData.isAuth,
  98. isAuthPhone:getApp().globalData.user_phone,
  99. userInfoObj:{},
  100. userStatus:'点击申请',
  101. }
  102. },
  103. onLoad() {
  104. },
  105. onShow() {
  106. this.getUserInfo();
  107. },
  108. methods: {
  109. switchUserStatus(status){
  110. console.log(status)
  111. let that = this;
  112. switch (status){
  113. case '1':
  114. that.userStatus = '审核中'+'&nbsp;&nbsp;&nbsp;'
  115. break;
  116. case '2':
  117. that.userStatus = '已认证'+'&nbsp;&nbsp;&nbsp;'
  118. break;
  119. case '3':
  120. that.userStatus = '已禁用'+'&nbsp;&nbsp;&nbsp;'
  121. break;
  122. case '4':
  123. that.userStatus = '点击申请'
  124. break;
  125. default:
  126. that.userStatus = '点击申请'
  127. break;
  128. }
  129. },
  130. getUserInfo(){
  131. let that = this;
  132. uni.request({
  133. url: getApp().globalData.shareUrl, //需要设置为全局
  134. method: 'POST',
  135. header: {
  136. 'content-type': 'application/x-www-form-urlencoded'
  137. },
  138. data: {
  139. method: 'getUserInfo',
  140. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  141. uid:getApp().globalData.user_id,
  142. sign: md5('getUserInfo' + getApp().globalData.globalTimestamp)
  143. },
  144. success: res => {
  145. if (res.data.code === 200) {
  146. console.log(res.data.msg)
  147. that.userInfoObj = res.data.msg;
  148. that.isAuth = res.data.msg.auth_status === '1';
  149. that.isAuthPhone = res.data.msg.phone;
  150. that.switchUserStatus(res.data.msg.status)
  151. if(that.isAuth){
  152. that.userName = getApp().globalData.user_name;
  153. that.userHead = getApp().globalData.user_headUrl;
  154. }
  155. if(that.isAuthPhone){
  156. that.userPhone = res.data.msg.phone;
  157. }
  158. //that.cashOutList = res.data.msg
  159. }
  160. }
  161. });
  162. },
  163. goTeamDetail(){
  164. if(getApp().globalData.isAuth){
  165. uni.navigateTo({
  166. url: '/pages/selfCenter/recommendTeam/index',
  167. success: res => {},
  168. fail: () => {},
  169. complete: () => {}
  170. });
  171. }else {
  172. this.goAuth()
  173. }
  174. },
  175. goRecommend(){
  176. uni.switchTab({
  177. url:'/pages/index/index'
  178. })
  179. },
  180. goAward(){
  181. if(getApp().globalData.isAuth){
  182. uni.navigateTo({
  183. url: '/pages/selfCenter/awardPage/index',
  184. success: res => {},
  185. fail: () => {},
  186. complete: () => {}
  187. });
  188. }else {
  189. this.goAuth()
  190. }
  191. },
  192. goCashOut(){
  193. if(getApp().globalData.isAuth){
  194. uni.navigateTo({
  195. url: '/pages/selfCenter/cashoutPage/index',
  196. success: res => {},
  197. fail: () => {},
  198. complete: () => {}
  199. });
  200. }else {
  201. this.goAuth()
  202. }
  203. },
  204. goHelpPage(){
  205. uni.navigateTo({
  206. url: '/pages/selfCenter/helpPage/index',
  207. success: res => {},
  208. fail: () => {},
  209. complete: () => {}
  210. });
  211. },
  212. applyPower(){
  213. let that = this;
  214. if(that.userStatus === '点击申请'){
  215. that.getUserIsApply()
  216. }else{
  217. return false;
  218. }
  219. },
  220. getUserIsApply(){
  221. let that = this;
  222. uni.request({
  223. url: getApp().globalData.shareUrl, //需要设置为全局
  224. method: 'POST',
  225. header: {
  226. 'content-type': 'application/x-www-form-urlencoded'
  227. },
  228. data: {
  229. method: 'getApplyCompetency',
  230. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  231. uid:getApp().globalData.user_id,
  232. sign: md5('getApplyCompetency' + getApp().globalData.globalTimestamp)
  233. },
  234. success: res => {
  235. if (res.data.code === 200) {
  236. if(res.data.msg.status === 1){
  237. that.$refs.showtip.open()
  238. }else {
  239. uni.showToast({
  240. title: '您没有权限申请分销资格',
  241. icon: 'none',
  242. duration:3000
  243. });
  244. }
  245. }else {
  246. uni.showToast({
  247. title: res.data.msg,
  248. icon: 'none',
  249. duration:3000
  250. });
  251. }
  252. }
  253. });
  254. },
  255. submitApply(){
  256. let that = this;
  257. uni.request({
  258. url: getApp().globalData.shareUrl, //需要设置为全局
  259. method: 'POST',
  260. header: {
  261. 'content-type': 'application/x-www-form-urlencoded'
  262. },
  263. data: {
  264. method: 'zigeapply',
  265. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  266. uid:getApp().globalData.user_id,
  267. sign: md5('zigeapply' + getApp().globalData.globalTimestamp)
  268. },
  269. success: res => {
  270. if (res.data.code === 200) {
  271. console.log(res.data.msg)
  272. that.$refs.showtip.close();
  273. that.userStatus = '审核中'+'&nbsp;&nbsp;&nbsp;';
  274. //that.cashOutList = res.data.msg
  275. }
  276. }
  277. });
  278. },
  279. cancel(type) {
  280. // this.userStatus = '审核中'+'&nbsp;&nbsp;&nbsp;'
  281. this.$refs.showtip.close()
  282. },
  283. change(e) {
  284. console.log('是否打开:' + e.show)
  285. },
  286. goAuth(){
  287. uni.navigateTo({
  288. url: '/pages/auth/index',
  289. success: res => {},
  290. fail: () => {},
  291. complete: () => {}
  292. });
  293. },
  294. changePhoneNumber(e){
  295. let that = this;
  296. console.log(e,'change')
  297. if (e.detail.errMsg == 'getPhoneNumber:ok') { //允许授权执行跳转
  298. console.log(e.detail.iv)
  299. that.phoneRequest(e.detail.iv, e.detail.encryptedData, getApp().globalData.session_key)
  300. }
  301. else {
  302. // that.isNeedPhone = false;
  303. }
  304. },
  305. getPhoneNumber(e){
  306. let that = this;
  307. console.log(e,'get')
  308. if (e.detail.errMsg == 'getPhoneNumber:ok') { //允许授权执行跳转
  309. console.log(e.detail.iv)
  310. that.phoneRequest(e.detail.iv, e.detail.encryptedData, getApp().globalData.session_key)
  311. }
  312. else {
  313. that.isNeedPhone = false;
  314. }
  315. },
  316. phoneRequest(myIv,myEncryptedData,sKey){
  317. console.log(11111)
  318. let that = this;
  319. uni.request({
  320. url:getApp().globalData.shareUrl, //需要设置为全局
  321. method: 'POST',
  322. header: {
  323. 'content-type': 'application/x-www-form-urlencoded'
  324. },
  325. data: {
  326. method: 'getPhoneNumber',
  327. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  328. uid:getApp().globalData.user_id,
  329. sign: md5('getPhoneNumber' + getApp().globalData.globalTimestamp),
  330. iv:myIv,
  331. sessionKey:sKey,
  332. encryptedData:myEncryptedData,
  333. },
  334. success: res => {
  335. if(res.data.code === 200){
  336. getApp().globalData.user_phone = res.data.msg.phoneNumber;
  337. that.userPhone = res.data.msg.phoneNumber;
  338. that.isAuthPhone = res.data.msg.phoneNumber;
  339. }
  340. }
  341. });
  342. },
  343. }
  344. }
  345. </script>
  346. <style>
  347. .content {
  348. display: flex;
  349. flex-direction: column;
  350. align-items: center;
  351. justify-content: center;
  352. }
  353. .selfInfo-box {
  354. width: 100%;
  355. height: 320rpx;
  356. background: #1fa1fb;
  357. padding-top: 5%;
  358. color: #fff;
  359. }
  360. .self-auth {
  361. display: flex;
  362. align-items: center;
  363. }
  364. .self-auth image {
  365. margin-left: 5%;
  366. height: 120rpx;
  367. width: 120rpx;
  368. border-radius: 50%;
  369. }
  370. .self-auth view {
  371. display: flex;
  372. flex-direction: column;
  373. /* align-items: center; */
  374. }
  375. .self-content {
  376. margin-top: 10%;
  377. display: flex;
  378. justify-content: space-around;
  379. align-items: center;
  380. }
  381. .self-content view {
  382. display: flex;
  383. flex-direction: column;
  384. align-items: center;
  385. }
  386. .function-box {
  387. display: flex;
  388. justify-content: space-around;
  389. align-items: center;
  390. background: #fff;
  391. width: 100%;
  392. height: 240rpx;
  393. }
  394. .function-content {
  395. display: flex;
  396. flex-direction: column;
  397. justify-content: space-around;
  398. align-items: center;
  399. background: #ff685a;
  400. width: 200rpx;
  401. height: 180rpx;
  402. border-radius: 10rpx;
  403. font-size: 30rpx;
  404. color: #fff;
  405. }
  406. .function-content image {
  407. width: 75rpx;
  408. height: 75rpx;
  409. margin-top: 5%;
  410. }
  411. .function-content text {
  412. margin-bottom: 5%;
  413. }
  414. .list-box {
  415. width: 100%;
  416. margin-top: 3%;
  417. font-size: 30rpx;
  418. }
  419. .list-content {
  420. background: #fff;
  421. display: flex;
  422. justify-content: space-between;
  423. align-items: center;
  424. height: 100rpx;
  425. border-bottom: 1px solid #dbdbdb;
  426. }
  427. .change-phone {
  428. padding-left: 0!important;
  429. padding-right: 0!important;
  430. color: #000!important;
  431. font-size: 30rpx!important;
  432. }
  433. .apply-box {
  434. display: flex;
  435. align-items: center;
  436. width: 200rpx;
  437. }
  438. .apply-box image {
  439. width: 50rpx;
  440. height: 50rpx;
  441. margin-right: 5%;
  442. }
  443. .margin-left5 {
  444. margin-left: 5%;
  445. }
  446. .authUser {
  447. width: 70%;
  448. font-size: 14px;
  449. background-color: #fff!important;
  450. color: #1fa1fb!important;
  451. }
  452. .authPhone {
  453. font-size: 12px;
  454. margin-left: ;
  455. margin-left: 10px;
  456. margin-top: 5px;
  457. background-color: #fff!important;
  458. color: #1fa1fb!important;
  459. }
  460. /* 提示窗口 */
  461. .uni-tip {
  462. padding: 15px;
  463. background: #fff;
  464. box-sizing: border-box;
  465. border-radius: 10px;
  466. }
  467. .uni-tip-title {
  468. text-align: center;
  469. /* font-weight: bold; */
  470. font-size: 28upx;
  471. color: #333;
  472. }
  473. .uni-tip-content {
  474. font-size: 14px;
  475. color: #666;
  476. }
  477. .uni-tip-group-button {
  478. margin-top: 10px;
  479. display: flex;
  480. }
  481. .uni-tip-button {
  482. width: 100%;
  483. text-align: center;
  484. font-size: 14px;
  485. color: #3b4144;
  486. }
  487. </style>