user.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. <template>
  2. <view>
  3. <view :class="'mine' + (skinNotColor ? ' not-color' : '')">
  4. <image src="/static/images/wdbg.png" class="wdbg"
  5. @click="jumpUrl('mine/userinfo/userinfo')"></image>
  6. <view class="minec">
  7. <image :src="userInfos.avatar ? userInfos.avatar : '/static/pages/images/userimg.png'" mode="aspectFit"
  8. class="user" @click="jumpUrl('mine/userinfo/userinfo')"></image>
  9. <view class="mines" @click="jumpUrl('mine/userinfo/userinfo')" v-if="isLogin">
  10. <view class="ddflex">{{userInfos.nickName}}
  11. <image :src="config.ordinary_member_icon" class="common-vip"
  12. v-if="config.ordinary_member_icon&&!userinfovip.levelGrade"></image>
  13. </view>
  14. <text class="edu" v-if="userInfos.mobile">{{userInfos.mobile}}</text>
  15. </view>
  16. <view class="flex" v-else>
  17. <text class="login-btn" @click="jumpUrl('')">点击登录</text>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="yichang-box ddflex">
  22. <view class="yichang-item fflex" @click="jumpUrl('warning/abnormalAlarm/abnormalAlarm')">
  23. <view class="yichang-title">异常告警</view>
  24. <view class="yichang-data">10<text class="symbol">条</text></view>
  25. <view class="yichang-btn">去查看</view>
  26. <image src="../../static/images/ycjg.png"></image>
  27. </view>
  28. <view class="yichang-item fflex" style="margin-left: 26rpx;" @click="jumpUrl('warning/orderAlarm/orderAlarm')">
  29. <view class="yichang-title">异常处理</view>
  30. <view class="yichang-data">10<text class="symbol">个</text></view>
  31. <view class="yichang-btn">去处理</view>
  32. <image src="../../static/images/yccl.png"></image>
  33. </view>
  34. </view>
  35. <view class="order">
  36. <view class="tits dflex">
  37. <view class="flex">我的服务</view>
  38. </view>
  39. <view class="list2 dflex">
  40. <navigator url="" hover-class="none" class="li" @click="jumpUrl('mine/order/order')">
  41. <image src="../../static/pages/images/user_service1.png"></image>
  42. <text>我的订单</text>
  43. </navigator>
  44. <navigator url="" hover-class="none" class="li" @click="jumpUrl('pages/myMerchant/myMerchant')">
  45. <image src="../../static/pages/images/user_service2.png"></image>
  46. <text>我的商家</text>
  47. </navigator>
  48. <navigator url="" hover-class="none" class="li" @click="jumpUrl('integralshop/index/index')">
  49. <image src="../../static/pages/images/user_service3.png"></image>
  50. <text>我的门店</text>
  51. </navigator>
  52. <navigator url="" hover-class="none" class="li" @click="jumpUrl('pages/operationData/operationData')">
  53. <image src="../../static/pages/images/user_service4.png"></image>
  54. <text>运营数据</text>
  55. </navigator>
  56. <view class="li">
  57. <contact-button img-url="../../static/pages/images/user_service5.png" img-style='width: 74rpx;height: 74rpx;margin: 0 auto 12rpx;' button-text="官方客服" styles="line-height:initial;"></contact-button>
  58. </view>
  59. <navigator url="/pages/about/about" hover-class="none" class="li">
  60. <image src="../../static/pages/images/user_service6.png"></image>
  61. <text>关于我们</text>
  62. </navigator>
  63. <navigator url="/mine/feedback/feedback" hover-class="none" class="li">
  64. <image src="../../static/pages/images/user_service7.png"></image>
  65. <text>建议反馈</text>
  66. </navigator>
  67. <navigator url="/mine/feedback/feedback" hover-class="none" class="li">
  68. <image src="../../static/pages/images/user_service8.png"></image>
  69. <text>退出登录</text>
  70. </navigator>
  71. </view>
  72. </view>
  73. <!-- 注册成为会员 -->
  74. <view class="mask" :hidden="isHide" @tap="hideRegister"></view>
  75. <view class="regi" :hidden="isHide">
  76. <view class="regi-tit">注册会员<image src="/static/pages/images/close1.png" class="regi-close"
  77. @tap="hideRegister"></image>
  78. </view>
  79. <view class="phone dflex">
  80. <input placeholder="手机号" placeholder-class="placeholder" class="flex"></input>
  81. <button open-type="getPhoneNumber" @getphonenumber="getphonenumber" class="getphone dflex">
  82. <image src="/static/pages/images/wxico.png"></image>一键获取
  83. </button>
  84. </view>
  85. <view class="regi-btn">立即注册</view>
  86. </view>
  87. <footer-copyright></footer-copyright>
  88. <!-- <view class="placeholder-view" :style="'height:' + (bottomBlankHeignt + 115) + 'rpx'"></view> -->
  89. <foot channel="user" :isUpdate="isUpdate"></foot>
  90. <update-userinfo :update-info="isUpdateInfo" :update-mobile="isUpdateMobile" v-if="isShowUpdate" @closeUpdate="closeUpdate" @updateInfo="updateInfo" @updateMobile="updateMobile"></update-userinfo>
  91. <!-- <web-view src="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx86937a61b8d50977&redirect_uri=https%3a%2f%2fwebtest.tongyu99.com&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"></web-view> -->
  92. </view>
  93. </template>
  94. <script>
  95. // pages/user/user.js
  96. const app = getApp();
  97. const req = require("../../utils/request.js");
  98. const route = require("../../utils/route");
  99. import foot from "../../components/nav-bar/index";
  100. import footerCopyright from "../../components/footer-copyright/footer-copyright";
  101. export default {
  102. data() {
  103. return {
  104. skinNotColor: req.public.skinNotColor,
  105. picUrlss: req.public.picUrls,
  106. bottomBlankHeignt: app.globalData.isIPhoneX ? 68 : 0,
  107. // merchantId: '',
  108. iconSrc: req.public.iconSrc,
  109. //头部页面背景链接
  110. isUpdate: false,
  111. // 是否更新消息
  112. isHideVip: true,
  113. //隐藏会员
  114. isVip: true,
  115. //是否是会员
  116. isHide: true,
  117. //是否隐藏注册会员弹窗
  118. IS_secondary_members: 0,
  119. distr: "",
  120. userinfovip: "",
  121. userMoney: "",
  122. istetphone: "",
  123. logo: "",
  124. name: "",
  125. is_open_wallet: "",
  126. Open_Points_Mall: "",
  127. statistics: "",
  128. vipList: "",
  129. rongkang: req.header.appId,
  130. isSign: '',
  131. sign: 0,
  132. isLogin: false,
  133. noLogin: false,
  134. is_open_shop: '',
  135. isShowSign: false, //是否显示签到按钮
  136. config: {},
  137. userInfos: {},
  138. newsCount: 0,
  139. isShowUpdate: false,//是否显示更新信息弹窗
  140. isUpdateInfo: false,//更新用户信息
  141. isUpdateMobile: false,//绑定手机号
  142. };
  143. },
  144. components: {
  145. foot,
  146. footerCopyright
  147. },
  148. props: {},
  149. onLoad(options) {
  150. app.globalData.getCheckSessoin(json => {
  151. this.sessionKey = json.session_key;
  152. });
  153. uni.setNavigationBarColor({
  154. frontColor: this.skinNotColor ? '#000' : '#ffffff',
  155. backgroundColor: this.skinNotColor ? '#fff' : req.public.titleTopBgColor
  156. });
  157. if (JSON.parse(req.getStorage('configRes')).IS_secondary_members) {
  158. let IS_secondary_members = JSON.parse(req.getStorage('configRes')).IS_secondary_members;
  159. console.log(IS_secondary_members)
  160. this.setData({
  161. IS_secondary_members: IS_secondary_members
  162. });
  163. }
  164. let userInfo = req.getStorage('userInfo');
  165. if(req.isAuth()){
  166. setTimeout(res=>{
  167. if(!userInfo.avatar || userInfo.nickName == '微信用户' || this.userInfos.nickName == '微信用户'){
  168. this.isShowUpdate = true
  169. this.isUpdateInfo = true
  170. }
  171. if(userInfo.avatar&&!userInfo.mobile&&(this.userInfos&&!this.userInfos.mobile)){
  172. this.isShowUpdate = true
  173. this.isUpdateMobile = true
  174. }
  175. },2000)
  176. }
  177. },
  178. onShow: function() {
  179. this.setData({
  180. isUpdate: !this.isUpdate
  181. }); // let merchantId = req.getStorage('userInfo').merchantId
  182. // this.setData({
  183. // merchantId: merchantId,
  184. // })
  185. // console.log(this.merchantId);
  186. // this.getMy();
  187. // this.getAbout();
  188. // console.log(this.noLogin, 111111111111)
  189. let userInfo = req.getStorage('userInfo');
  190. // if (userInfo) this.isLogin = true;
  191. this.isLogin = req.isAuth();
  192. if (this.isLogin) {
  193. this.getMy();
  194. this.getNewsCount();
  195. this.getAbout();
  196. this.getRule();
  197. this.noLogin = true;
  198. } else {
  199. this.noLogin = false;
  200. }
  201. },
  202. methods: {
  203. jumpUrl(url) {
  204. if (!req.isLogin()) return false;
  205. app.globalData.navigateTo(url);
  206. },
  207. jumpMerchantManage() {
  208. // jumpUrl('pages/web/web')
  209. let token = req.getStorage('AUTH_TOKEN');
  210. this.jumpUrl('merchant/index?appId=' + req.header.appId + '&token=' + token);
  211. },
  212. // 是否签到{}
  213. isSignFun() {
  214. req.getRequest('/api/integral/isSign', {}, res => {
  215. this.setData({
  216. isSign: res
  217. });
  218. });
  219. },
  220. gouserInfo() {
  221. app.globalData.navigateTo('mine/userinfo/userinfo')
  222. },
  223. getDistributionConfig() {
  224. req.postRequest('/api/distribution/config', {}, res => {
  225. this.setData({
  226. distr: res
  227. });
  228. });
  229. },
  230. // 签到
  231. signFun() {
  232. req.postRequest('/api/integral/sign', {}, data => {
  233. if (data) {
  234. req.msg('连续签到' + data.continuityDay + '天' + ',获得' + data.IntegralChange + '积分');
  235. this.setData({
  236. sign: 1
  237. });
  238. this.getOpenPonints();
  239. }
  240. });
  241. },
  242. getuserVip() {
  243. req.getRequest('/api/user/levelDetails', {}, data => {
  244. let expireTime = Array;
  245. if (data.expireTime) {
  246. expireTime = data.expireTime.split(" ");
  247. data.expireTime = data.expireTime.replace(/-/g, '/');
  248. } // 解决苹果不兼容---日期
  249. // data.expireTime=data.expireTime.replace(/-/g, '/')
  250. let nowTime = new Date().getTime();
  251. let endTime = new Date(data.expireTime).getTime();
  252. let times = parseInt((endTime - nowTime) / 1000); // var expireTime= new Date(data.expireTime)
  253. // var time1=expireTime.getTime();
  254. // console.log(times, nowTime, endTime, data.expireTime);
  255. this.setData({
  256. userinfovip: data,
  257. ['userinfovip.expireTime']: expireTime[0]
  258. });
  259. if (times <= 0) {
  260. this.setData({
  261. ['userinfovip.end']: true
  262. });
  263. } else {
  264. this.setData({
  265. ['userinfovip.end']: false
  266. });
  267. }
  268. // console.log(data);
  269. });
  270. },
  271. getOpenPonints() {
  272. req.getRequest('/api/integral/returnIntegral', {}, res => {
  273. this.setData({
  274. integral: res
  275. })
  276. })
  277. },
  278. getMy() {
  279. let that = this;
  280. req.getRequest('/api/user/my', {}, data => {
  281. // data.merchantId = req.getStorage('userInfo').merchantId
  282. data.nickName = req.excludeSpecial(data.nickName);
  283. this.userInfos = data;
  284. let userInfo = req.getStorage('userInfo');
  285. userInfo.isDistriUser = this.userInfos.isDistriUser;
  286. req.setStorage('userInfo', userInfo);
  287. // that.setData(data); // this.isbindmobile();
  288. console.log('userinfo==' + JSON.stringify(data))
  289. this.isSignFun();
  290. this.getstatistics(data);
  291. this.getDistributionConfig();
  292. this.getuserVip();
  293. this.getuserMoney();
  294. this.getVip();
  295. this.getOpenPonints();
  296. // console.log(this);
  297. });
  298. },
  299. getuserMoney() {
  300. let is_open_wallet = JSON.parse(req.getStorage('configRes')).is_open_wallet;
  301. if (is_open_wallet) {
  302. if (JSON.parse(is_open_wallet).isOpenWallet == 1) {
  303. route.extendNew({}, res => {
  304. // console.log(parseFloat(res.all).toFixed(2));
  305. if (res) this.setData({
  306. userMoney: parseFloat(res.all).toFixed(2)
  307. });
  308. });
  309. }
  310. }
  311. },
  312. getNewsCount(){
  313. req.getRequest('/api/v3/fabulous/countComment',{},res=>{
  314. this.newsCount = res;
  315. })
  316. },
  317. getAbout() {
  318. var _this = this;
  319. req.getRequest('/api/config', {}, function(res) {
  320. _this.phone = res.CONFIG_SERVICE_HOT_MOBILE;
  321. _this.config = res;
  322. _this.setData({
  323. istetphone: res.user_bind_mobile,
  324. logo: res.CONFIG_PROJECT_LOGO,
  325. name: res.CONFIG_PROJECT_TITLE
  326. });
  327. // console.log(res);
  328. if (res && res.is_open_wallet) {
  329. _this.setData({
  330. is_open_wallet: JSON.parse(res.is_open_wallet)
  331. });
  332. }
  333. if (res.is_open_shop) {
  334. _this.is_open_shop = res.is_open_shop;
  335. }
  336. // if (res.user_bind_mobile == '1') {
  337. // let userInfo = req.getStorage('userInfo');
  338. // if (userInfo && (userInfo.mobile == null || userInfo.mobile == '')) {
  339. // app.globalData.openPage('pages/authorize/authorize?bindmobile=1');
  340. // }
  341. // }
  342. });
  343. // 是否开启积分商城
  344. req.getRequest('/api/params/value', {
  345. type: 'Open_Points_Mall'
  346. }, res => {
  347. this.setData({
  348. Open_Points_Mall: res
  349. });
  350. });
  351. },
  352. getphonenumber(event) {
  353. const detail = event.detail;
  354. const _ts = this;
  355. if (!detail || !detail.encryptedData || !detail.iv) return false;
  356. req.postRequest('/api/weixin/mobile', {
  357. encryptedData: detail.encryptedData,
  358. iv: detail.iv,
  359. sessionKey: this.sessionKey
  360. }, res => {
  361. _ts.getMy();
  362. });
  363. },
  364. callPhone() {
  365. if (!req.isLogin()) return false;
  366. uni.makePhoneCall({
  367. phoneNumber: this.phone
  368. });
  369. },
  370. showRegister() {
  371. //显示注册会员弹窗
  372. this.setData({
  373. isHide: false
  374. });
  375. },
  376. hideRegister() {
  377. //隐藏注册会员弹窗
  378. this.setData({
  379. isHide: true
  380. });
  381. },
  382. goUrl() {
  383. app.globalData.openPage('mine/vip/vip');
  384. },
  385. // 门店统计
  386. getstatistics(data) {
  387. let from = {};
  388. if (data.listShopBase && data.listShopBase != null && data.listShopBase.length > 0) {
  389. from.shopId = data.listShopBase[0].id;
  390. }
  391. if (data.listMerchant && data.listMerchant != null && data.listMerchant.length > 0 && data.listShopBase
  392. .length < 1) {
  393. from.merchantId = data.listMerchant[0].id;
  394. }
  395. req.getRequest('/api/order/statistics', from, data => {
  396. this.setData({
  397. statistics: data
  398. });
  399. console.log(data);
  400. });
  401. },
  402. getRule() {
  403. let that = this;
  404. req.getRequest('/api/integral/config', {}, res => {
  405. if (res && res.length > 0) {
  406. res.map(it => {
  407. if (it.illustrate && it.illustrate.indexOf('签到') > -1) {
  408. if (it.state == 2) {
  409. that.isShowSign = true;
  410. }
  411. }
  412. })
  413. }
  414. })
  415. },
  416. getVipListOrg() {
  417. if (this.vipList && this.userinfovip) {
  418. if(!this.userinfovip.levelGrade){
  419. this.vipList.map((it,index)=>{
  420. this.vipList[0].isShowInfo = true;
  421. })
  422. }else{
  423. this.vipList.map((it,index)=>{
  424. if(this.userinfovip.level == it.id){
  425. if(index < this.vipList.length-1){
  426. this.vipList[index+1].isShowInfo = true;
  427. }
  428. }
  429. })
  430. }
  431. }
  432. },
  433. getVip() {
  434. req.getRequest('/api/levelStrategy/userLevelList', {}, data => {
  435. if (data && data.length > 0) {
  436. data.map((it,index) => {
  437. it.upgradeTerm = JSON.parse(it.upgradeTerm)
  438. it.isShowInfo = false
  439. // if(index == 0) it.isShowInfo = true;
  440. return it;
  441. })
  442. this.vipList = data
  443. this.getVipListOrg();
  444. }
  445. });
  446. },
  447. showInfo(index) {
  448. if(!this.vipList[index].isShowInfo){
  449. this.vipList.map(it=>{
  450. it.isShowInfo = false;
  451. return it
  452. })
  453. }
  454. this.vipList[index].isShowInfo = !this.vipList[index].isShowInfo
  455. },
  456. closeUpdate(){
  457. this.isShowUpdate = false
  458. },
  459. updateInfo(e){
  460. this.isUpdateInfo = e
  461. this.getMy()
  462. },
  463. updateMobile(e){
  464. this.isUpdateMobile = e
  465. this.getMy()
  466. },
  467. // 判断强制绑定手机号
  468. // isbindmobile() {
  469. // if (req.getStorage('configRes')) {
  470. // let configRes = JSON.parse(req.getStorage('configRes'))
  471. // this.setData({ istetphone: configRes.user_bind_mobile, logo: configRes.CONFIG_PROJECT_LOGO, name: configRes.CONFIG_PROJECT_TITLE })
  472. // } else {
  473. // req.g('/api/config', (res) => {
  474. // req.setStorage('configRes', JSON.stringify(res))
  475. // this.setData({ istetphone: res.user_bind_mobile, logo: res.CONFIG_PROJECT_LOGO, name: res.CONFIG_PROJECT_TITLE })
  476. // })
  477. // }
  478. // if(this.data.istetphone=='1'){
  479. // // 获取用户手机号
  480. // let userInfo= req.getStorage('userInfo')
  481. // if(userInfo.mobile==null||userInfo.mobile==''){
  482. // console.log("获取用户手机号===============================")
  483. // app.openPage('pages/authorize/authorize?bindmobile=1')
  484. // }
  485. // }
  486. // },
  487. }
  488. };
  489. </script>
  490. <style>
  491. @import "./user.css";
  492. </style>