index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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.isAuthPhone){
  215. if(that.userStatus === '点击申请'){
  216. that.getUserIsApply()
  217. }else{
  218. return false;
  219. }
  220. }else {
  221. this.goAuth()
  222. }
  223. },
  224. getUserIsApply(){
  225. let that = this;
  226. uni.request({
  227. url: getApp().globalData.shareUrl, //需要设置为全局
  228. method: 'POST',
  229. header: {
  230. 'content-type': 'application/x-www-form-urlencoded'
  231. },
  232. data: {
  233. method: 'getApplyCompetency',
  234. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  235. uid:getApp().globalData.user_id,
  236. sign: md5('getApplyCompetency' + getApp().globalData.globalTimestamp)
  237. },
  238. success: res => {
  239. if (res.data.code === 200) {
  240. if(res.data.msg.status === 1){
  241. that.$refs.showtip.open()
  242. }else {
  243. uni.showToast({
  244. title: '您没有权限申请分销资格',
  245. icon: 'none',
  246. duration:3000
  247. });
  248. }
  249. }else {
  250. uni.showToast({
  251. title: res.data.msg,
  252. icon: 'none',
  253. duration:3000
  254. });
  255. }
  256. }
  257. });
  258. },
  259. submitApply(){
  260. let that = this;
  261. uni.request({
  262. url: getApp().globalData.shareUrl, //需要设置为全局
  263. method: 'POST',
  264. header: {
  265. 'content-type': 'application/x-www-form-urlencoded'
  266. },
  267. data: {
  268. method: 'zigeapply',
  269. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  270. uid:getApp().globalData.user_id,
  271. sign: md5('zigeapply' + getApp().globalData.globalTimestamp)
  272. },
  273. success: res => {
  274. if (res.data.code === 200) {
  275. console.log(res.data.msg)
  276. that.$refs.showtip.close();
  277. that.userStatus = '审核中'+'&nbsp;&nbsp;&nbsp;';
  278. //that.cashOutList = res.data.msg
  279. }
  280. }
  281. });
  282. },
  283. cancel(type) {
  284. // this.userStatus = '审核中'+'&nbsp;&nbsp;&nbsp;'
  285. this.$refs.showtip.close()
  286. },
  287. change(e) {
  288. console.log('是否打开:' + e.show)
  289. },
  290. goAuth(){
  291. uni.navigateTo({
  292. url: '/pages/auth/index',
  293. success: res => {},
  294. fail: () => {},
  295. complete: () => {}
  296. });
  297. },
  298. changePhoneNumber(e){
  299. let that = this;
  300. console.log(e,'change')
  301. if (e.detail.errMsg == 'getPhoneNumber:ok') { //允许授权执行跳转
  302. console.log(e.detail.iv)
  303. that.phoneRequest(e.detail.iv, e.detail.encryptedData, getApp().globalData.session_key)
  304. }
  305. else {
  306. // that.isNeedPhone = false;
  307. }
  308. },
  309. getPhoneNumber(e){
  310. let that = this;
  311. console.log(e,'get')
  312. if (e.detail.errMsg == 'getPhoneNumber:ok') { //允许授权执行跳转
  313. console.log(e.detail.iv)
  314. that.phoneRequest(e.detail.iv, e.detail.encryptedData, getApp().globalData.session_key)
  315. }
  316. else {
  317. that.isNeedPhone = false;
  318. }
  319. },
  320. phoneRequest(myIv,myEncryptedData,sKey){
  321. console.log(11111)
  322. let that = this;
  323. uni.request({
  324. url:getApp().globalData.shareUrl, //需要设置为全局
  325. method: 'POST',
  326. header: {
  327. 'content-type': 'application/x-www-form-urlencoded'
  328. },
  329. data: {
  330. method: 'getPhoneNumber',
  331. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  332. uid:getApp().globalData.user_id,
  333. sign: md5('getPhoneNumber' + getApp().globalData.globalTimestamp),
  334. iv:myIv,
  335. sessionKey:sKey,
  336. encryptedData:myEncryptedData,
  337. },
  338. success: res => {
  339. if(res.data.code === 200){
  340. getApp().globalData.user_phone = res.data.msg.phoneNumber;
  341. that.userPhone = res.data.msg.phoneNumber;
  342. that.isAuthPhone = res.data.msg.phoneNumber;
  343. }
  344. }
  345. });
  346. },
  347. }
  348. }
  349. </script>
  350. <style>
  351. .content {
  352. display: flex;
  353. flex-direction: column;
  354. align-items: center;
  355. justify-content: center;
  356. }
  357. .selfInfo-box {
  358. width: 100%;
  359. height: 320rpx;
  360. background: #1fa1fb;
  361. padding-top: 5%;
  362. color: #fff;
  363. }
  364. .self-auth {
  365. display: flex;
  366. align-items: center;
  367. }
  368. .self-auth image {
  369. margin-left: 5%;
  370. height: 120rpx;
  371. width: 120rpx;
  372. border-radius: 50%;
  373. }
  374. .self-auth view {
  375. display: flex;
  376. flex-direction: column;
  377. /* align-items: center; */
  378. }
  379. .self-content {
  380. margin-top: 10%;
  381. display: flex;
  382. justify-content: space-around;
  383. align-items: center;
  384. }
  385. .self-content view {
  386. display: flex;
  387. flex-direction: column;
  388. align-items: center;
  389. }
  390. .function-box {
  391. display: flex;
  392. justify-content: space-around;
  393. align-items: center;
  394. background: #fff;
  395. width: 100%;
  396. height: 240rpx;
  397. }
  398. .function-content {
  399. display: flex;
  400. flex-direction: column;
  401. justify-content: space-around;
  402. align-items: center;
  403. background: #ff685a;
  404. width: 200rpx;
  405. height: 180rpx;
  406. border-radius: 10rpx;
  407. font-size: 30rpx;
  408. color: #fff;
  409. }
  410. .function-content image {
  411. width: 75rpx;
  412. height: 75rpx;
  413. margin-top: 5%;
  414. }
  415. .function-content text {
  416. margin-bottom: 5%;
  417. }
  418. .list-box {
  419. width: 100%;
  420. margin-top: 3%;
  421. font-size: 30rpx;
  422. }
  423. .list-content {
  424. background: #fff;
  425. display: flex;
  426. justify-content: space-between;
  427. align-items: center;
  428. height: 100rpx;
  429. border-bottom: 1px solid #dbdbdb;
  430. }
  431. .change-phone {
  432. padding-left: 0!important;
  433. padding-right: 0!important;
  434. color: #000!important;
  435. font-size: 30rpx!important;
  436. }
  437. .apply-box {
  438. display: flex;
  439. align-items: center;
  440. width: 200rpx;
  441. }
  442. .apply-box image {
  443. width: 50rpx;
  444. height: 50rpx;
  445. margin-right: 5%;
  446. }
  447. .margin-left5 {
  448. margin-left: 5%;
  449. }
  450. .authUser {
  451. width: 70%;
  452. font-size: 14px;
  453. background-color: #fff!important;
  454. color: #1fa1fb!important;
  455. }
  456. .authPhone {
  457. font-size: 12px;
  458. margin-left: ;
  459. margin-left: 10px;
  460. margin-top: 5px;
  461. background-color: #fff!important;
  462. color: #1fa1fb!important;
  463. }
  464. /* 提示窗口 */
  465. .uni-tip {
  466. padding: 15px;
  467. background: #fff;
  468. box-sizing: border-box;
  469. border-radius: 10px;
  470. }
  471. .uni-tip-title {
  472. text-align: center;
  473. /* font-weight: bold; */
  474. font-size: 28upx;
  475. color: #333;
  476. }
  477. .uni-tip-content {
  478. font-size: 14px;
  479. color: #666;
  480. }
  481. .uni-tip-group-button {
  482. margin-top: 10px;
  483. display: flex;
  484. }
  485. .uni-tip-button {
  486. width: 100%;
  487. text-align: center;
  488. font-size: 14px;
  489. color: #3b4144;
  490. }
  491. </style>