Mine.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. <template>
  2. <view class="container">
  3. <view class="userInfoBox">
  4. <view class="userHeader">
  5. <image class="userImg" :src="userImg || '../../static/img/mine/userImg.png'"></image>
  6. <view class="userNameBox">
  7. <view class="userName">{{userName || '点击登录'}}</view>
  8. <button v-if="!openID" class="loginBtn" open-type="getPhoneNumber" @getphonenumber="login">手机号快捷登录</button>
  9. </view>
  10. </view>
  11. <view class="userNumBox">
  12. <view class="userNumItem">
  13. <text class="userNum">{{rewardToday == -1 ? '--' : ('¥' + rewardToday)}}</text>
  14. <text class="userNumTitle">今日已领奖励</text>
  15. </view>
  16. <view class="userNumItem">
  17. <text class="userNum">{{rewardHistory == -1 ? '--' : ('¥' + rewardHistory)}}</text>
  18. <text class="userNumTitle">历史已领奖励</text>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="userOrderBox">
  23. <view class="orderTitle">
  24. <text class="orderTitleText">我提交的线索</text>
  25. <text class="orderTitleMore" @tap="orderListTo('1')">查看全部 >></text>
  26. </view>
  27. <view class="orderContent">
  28. <view class="orderContentItem" @tap="orderListTo('2')">
  29. <view class="orderContentItemNum">{{noResponseNum == -1 ? '--' : noResponseNum}}</view>
  30. <view class="orderContentItemTitle">未回复</view>
  31. </view>
  32. <view class="orderContentItem" @tap="orderListTo('3')">
  33. <view class="orderContentItemNum">{{responsedNum == -1 ? '--' : responsedNum}}</view>
  34. <view class="orderContentItemTitle">已回复</view>
  35. </view>
  36. <view class="orderContentItem" @tap="orderListTo('4')">
  37. <view class="orderContentItemNum">{{evaluateNum == -1 ? '--' : evaluateNum}}</view>
  38. <view class="orderContentItemTitle">已评价</view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="moreServiceBox" v-if="openID">
  43. <view class="moreServiceTitle">更多服务</view>
  44. <view class="moreServiceContent">
  45. <view class="serviceContentItem" @tap="onMyRewardTo" v-if="openID">
  46. <image class="serviceContentItemImg" src="../../static/img/mine/myReward.png"></image>
  47. <view class="serviceContentItemTitle">我的奖励</view>
  48. <image class="serviceContentItemIcon" src="../../static/img/mine/right.png"></image>
  49. </view>
  50. <view class="serviceContentItem" v-if="userType == '2' && openID" @tap="onGridmanRewardTo">
  51. <!-- <view class="serviceContentItem" @tap="onGridmanRewardTo" v-if="openID"> -->
  52. <image class="serviceContentItemImg" src="../../static/img/mine/gridmanReward.png"></image>
  53. <view class="serviceContentItemTitle">网格员奖励与补领</view>
  54. <image class="serviceContentItemIcon" src="../../static/img/mine/right.png"></image>
  55. </view>
  56. <!-- <view class="serviceContentItem" @tap="onInvitationTo" v-if="openID && userType == '1'">
  57. <image class="serviceContentItemImg" src="../../static/img/mine/invitation.png"></image>
  58. <view class="serviceContentItemTitle">邀请码</view>
  59. <image class="serviceContentItemIcon" src="../../static/img/mine/right.png"></image>
  60. </view> -->
  61. <!-- <view class="serviceContentItem" @tap="onGZHTo">
  62. <image class="serviceContentItemImg" src="../../static/img/mine/weixin.png"></image>
  63. <view class="serviceContentItemTitle">关注公众号</view>
  64. <image class="serviceContentItemIcon" src="../../static/img/mine/right.png"></image>
  65. </view> -->
  66. <view class="serviceContentItem" @tap="loginOut" v-if="openID">
  67. <image class="serviceContentItemImg" src="../../static/img/mine/logout.png"></image>
  68. <view class="serviceContentItemTitle">退出登录</view>
  69. <image class="serviceContentItemIcon" src="../../static/img/mine/right.png"></image>
  70. </view>
  71. </view>
  72. </view>
  73. <!-- 关注公众号弹窗 -->
  74. <view class="popMask" v-if="isPopShow">
  75. <view class="popContent">
  76. <view class="popTips">长按扫码关注公众号</view>
  77. <image class="popImg" src="../../static/img/mine/qrcode_gyyjgl.jpg" show-menu-by-longpress></image>
  78. <image class="popClose" src="../../static/img/mine/popClose.png" @tap="onGZHCloseTo"></image>
  79. </view>
  80. </view>
  81. <!-- 邀请码弹窗 -->
  82. <view class="popMask" v-if="isInvitationPopShow">
  83. <view class="popContent">
  84. <view class="popTips">邀请码</view>
  85. <view class="popBody">
  86. <view class="bindedTips" v-if="YQCode">已绑定邀请码:{{YQCode}}</view>
  87. <input type="number" class="fway-form-input" v-else placeholder="请填写邀请码" v-model="strYQCode" maxlength="4" />
  88. <view class="errorTips" v-if="!YQCode && errorTips">{{errorTips}}</view>
  89. </view>
  90. <view class="popBtnBox">
  91. <view class="popBtn" style="color: #777;" @tap="onInvitationCloseTo" v-if="!YQCode">取消</view>
  92. <view class="popBtn" style="color: #3e6ffd;" :style="{width: YQCode ? '100%' : '50%'}" @tap="onInvitationSubmitTo">确定</view>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 扫码登录弹窗 -->
  97. <view class="popMask" v-if="isLoginPopShow">
  98. <view class="popContent">
  99. <view class="popTips">请先登录</view>
  100. <view class="popBody" style="border-radius: 0 0 30rpx 30rpx;">
  101. <button v-if="!openID" class="loginPopBtn" open-type="getPhoneNumber" @getphonenumber="login">手机号快捷登录</button>
  102. <view class="loginPopBtn" style="background-color: #999;" @tap="onLoginCloseTo">取消</view>
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. </template>
  108. <script>
  109. var that,
  110. qqMap = require('@/static/js/qqmap-wx-jssdk.min.js'),
  111. qqMapsdk;
  112. export default {
  113. options: {
  114. styleIsolation: 'isolated'
  115. },
  116. data() {
  117. return {
  118. openID: '',
  119. userType: '1',
  120. userImg: '',
  121. userName: '',
  122. YQCode: '',
  123. isCity: '0',
  124. rewardToday: -1,
  125. rewardHistory: -1,
  126. noResponseNum: -1,
  127. responsedNum: -1,
  128. evaluateNum: -1,
  129. isPopShow: false,
  130. isInvitationPopShow: false,
  131. isLoginPopShow: false,
  132. strYQCode: '',
  133. strYQCodeID: '', // 扫码进入小程序获得
  134. errorTips: ''
  135. }
  136. },
  137. methods: {
  138. getData(option){
  139. that = this;
  140. // 实例化API核心类
  141. qqMapsdk = new qqMap({
  142. key: 'TE4BZ-ZFEAT-45CX3-VPZ3R-GOLS6-EGF54'
  143. });
  144. if (option && option.scene) {
  145. that.strYQCodeID = decodeURIComponent(option.scene);
  146. }
  147. },
  148. init() {
  149. let objUser = uni.getStorageSync('userInfo')
  150. that.openID = objUser.openID;
  151. that.userType = objUser.userType;
  152. that.YQCode = objUser.YQCode;
  153. that.userName = objUser.userTel ? objUser.userTel.slice(0, 3) + '******' + objUser.userTel.slice(-2) : '微信用户';
  154. if (that.openID) {
  155. that.onGetData();
  156. if (that.strYQCodeID){
  157. that.isInvitationPopShow = true;
  158. }
  159. }else {
  160. if (that.strYQCodeID){
  161. that.isLoginPopShow = true;
  162. }
  163. }
  164. },
  165. getAuthorizeInfo(fun) {
  166. uni.authorize({
  167. scope: 'scope.userLocation',
  168. success() { // 允许授权
  169. that.getLocationInfo(fun);
  170. },
  171. fail() { // 拒绝授权
  172. that.openConfirm(fun);
  173. }
  174. })
  175. },
  176. // 获取地理位置
  177. getLocationInfo(fun) {
  178. uni.getLocation({
  179. type: 'gcj02',
  180. success: function(res) {
  181. qqMapsdk.reverseGeocoder({
  182. location: {
  183. latitude: res.latitude,
  184. longitude: res.longitude
  185. },
  186. success(data) {
  187. // 地址信息
  188. let city = data.result.address_component.city;
  189. if (city == '自贡市') {
  190. that.isCity = '1';
  191. } else {
  192. that.isCity = '0';
  193. }
  194. typeof fun === 'function' && fun();
  195. }
  196. });
  197. }
  198. });
  199. },
  200. // 当用户第一次拒绝后再次请求授权
  201. openConfirm(fun) {
  202. uni.showModal({
  203. title: '请求授权当前位置',
  204. content: '需要获取您当前的所在城市,请确认授权',
  205. success: (res) => {
  206. if (res.confirm) {
  207. uni.openSetting({
  208. success(res) {
  209. if (res.authSetting['scope.userLocation']) {
  210. that.getLocationInfo(fun);
  211. } else {
  212. typeof fun === 'function' && fun();
  213. }
  214. }
  215. }); // 打开地图权限设置
  216. } else if (res.cancel) {
  217. uni.showToast({
  218. title: '你拒绝了授权,无法获得你所在城市信息',
  219. icon: 'none',
  220. duration: 1000,
  221. success() {
  222. typeof fun === 'function' && fun();
  223. }
  224. })
  225. }
  226. }
  227. });
  228. },
  229. onGetData() {
  230. that.$admin.req({
  231. method: 'GET',
  232. url: '/api/v1/Snapshot/user'
  233. }).then(res => {
  234. if (res) {
  235. that.rewardToday = res.dayAmount;
  236. that.rewardHistory = res.totalAmount;
  237. that.noResponseNum = res.noReplyCount;
  238. that.responsedNum = res.replyCount;
  239. that.evaluateNum = res.appraiseCount;
  240. }
  241. })
  242. },
  243. login(e) {
  244. if (e.detail.code){
  245. uni.login({
  246. provider: "weixin",
  247. onlyAuthorize: true,
  248. success: (login_res => {
  249. if (login_res.code) {
  250. that.$admin.reqDirect({
  251. method: 'POST',
  252. url: '/api/v1/Identity/third/token',
  253. data: {
  254. loginCode: login_res.code,
  255. telCode: e.detail.code,
  256. thirdType: 0
  257. }
  258. }).then(res => {
  259. if (res) {
  260. that.$admin.saveUserInfo(res, function(){
  261. that.$util.msg('登录成功!', function() {
  262. that.init();
  263. if (that.strYQCodeID) {
  264. that.isLoginPopShow = false;
  265. that.isInvitationPopShow = true;
  266. }
  267. });
  268. })
  269. } else {
  270. that.$util.msg('登录失败,请稍后重试');
  271. }
  272. })
  273. } else {
  274. that.$util.msg('登录失败,请重新操作');
  275. }
  276. })
  277. })
  278. }else {
  279. that.$util.msg('请授权手机号登录');
  280. }
  281. },
  282. orderListTo(type) {
  283. if (!that.openID) {
  284. that.$util.msg("请先登录");
  285. return;
  286. }
  287. uni.navigateTo({
  288. url: '/pagesCare/Order/List?tabIndex=' + type
  289. })
  290. },
  291. onMyRewardTo() {
  292. if (!that.openID) {
  293. that.$util.msg("请先登录");
  294. return;
  295. }
  296. uni.navigateTo({
  297. // url: '/pagesCare/MyReward/Index'
  298. url: '/pagesCare/MyReward/Index_Temp'
  299. })
  300. },
  301. onGridmanRewardTo() {
  302. if (!that.openID) {
  303. that.$util.msg("请先登录");
  304. return;
  305. }
  306. uni.navigateTo({
  307. url: '/pagesCare/GridmanReward/Index'
  308. })
  309. },
  310. // onSaveInviteCodeByID() {
  311. // if (that.strYQCodeID && !that.YQCode) {
  312. // that.onInvitationSave();
  313. // }
  314. // },
  315. onInvitationTo() {
  316. if (!that.openID) {
  317. that.$util.msg("请先登录");
  318. return;
  319. }
  320. that.isInvitationPopShow = true;
  321. },
  322. onInvitationSubmitTo() {
  323. if (that.YQCode) {
  324. that.isInvitationPopShow = false;
  325. that.strYQCodeID = '';
  326. } else {
  327. if (that.$util.e_checkNumber(that.strYQCode) === false) {
  328. that.errorTips = '请输入正确的邀请码!';
  329. return;
  330. }
  331. if (that.strYQCode.length != 4) {
  332. that.errorTips = '请输入4位正确的邀请码!';
  333. return;
  334. }
  335. that.onInvitationSave();
  336. }
  337. },
  338. onInvitationSave() {
  339. that.$admin.req({
  340. method: 'PUT',
  341. url: '/api/v1/Snapshot/third/invitationcode',
  342. data: {
  343. invitationCode: that.strYQCode
  344. }
  345. }).then(res => {
  346. that.$util.msg('邀请码绑定成功!', function() {
  347. that.YQCode = that.strYQCode;
  348. that.errorTips = '';
  349. that.strYQCode = '';
  350. that.strYQCodeID = '';
  351. let objUser = uni.getStorageSync('userInfo');
  352. objUser.YQCode = that.YQCode;
  353. uni.setStorageSync('userInfo', objUser);
  354. });
  355. }, err => {
  356. that.errorTips = err;
  357. })
  358. },
  359. onInvitationCloseTo() {
  360. that.isInvitationPopShow = false;
  361. that.strYQCodeID = '';
  362. },
  363. onLoginCloseTo() {
  364. that.isLoginPopShow = false;
  365. that.strYQCodeID = '';
  366. },
  367. onGZHTo() {
  368. that.isPopShow = true;
  369. },
  370. onGZHCloseTo() {
  371. that.isPopShow = false;
  372. },
  373. loginOut() {
  374. if (that.openID) {
  375. uni.showModal({
  376. title: '退出登录',
  377. content: '确定要退出登录吗?',
  378. success(res) {
  379. if (res.confirm) {
  380. that.openID = '';
  381. that.userType = '1';
  382. that.userImg = '';
  383. that.userName = '';
  384. that.YQCode = '';
  385. that.rewardToday = -1;
  386. that.rewardHistory = -1;
  387. that.noResponseNum = -1;
  388. that.responsedNum = -1;
  389. that.evaluateNum = -1;
  390. // 清楚缓存
  391. uni.removeStorageSync('userInfo');
  392. }
  393. }
  394. })
  395. } else {
  396. that.$util.msg("请先登录");
  397. }
  398. }
  399. }
  400. }
  401. </script>
  402. <style lang="less">
  403. .container {
  404. background-color: #F6F7F8;
  405. height: calc(100vh - 340rpx);
  406. }
  407. .userInfoBox {
  408. height: 380rpx;
  409. width: 100%;
  410. background-color: #3e6ffd;
  411. position: absolute;
  412. top: 0;
  413. left: 0;
  414. }
  415. .userHeader {
  416. padding: 30rpx 30rpx 40rpx;
  417. font-size: 0;
  418. }
  419. .userImg {
  420. display: inline-block;
  421. width: 160rpx;
  422. height: 160rpx;
  423. vertical-align: middle;
  424. margin-right: 20rpx;
  425. border-radius: 10rpx;
  426. }
  427. .userNameBox {
  428. display: inline-block;
  429. width: calc(100% - 180rpx);
  430. vertical-align: middle;
  431. position: relative;
  432. border-radius: 50rpx;
  433. }
  434. .userName {
  435. width: calc(100%);
  436. vertical-align: middle;
  437. font-size: 36rpx;
  438. color: #fff;
  439. }
  440. .loginBtn {
  441. width: 300rpx;
  442. text-align: center;
  443. background-color: #07c160;
  444. color: #fff;
  445. font-size: 32rpx;
  446. border-radius: 50rpx;
  447. height: 70rpx;
  448. line-height: 70rpx;
  449. margin-left: 0;
  450. margin-top: 40rpx;
  451. }
  452. .userNumBox {
  453. display: flex;
  454. justify-content: space-around;
  455. }
  456. .userNumItem {
  457. text-align: left;
  458. }
  459. .userNum {
  460. display: block;
  461. font-size: 40rpx;
  462. color: #fff;
  463. margin-bottom: 20rpx;
  464. }
  465. .userNumTitle {
  466. display: block;
  467. font-size: 34rpx;
  468. color: #fff;
  469. }
  470. .userOrderBox {
  471. margin: 340rpx 20rpx 30rpx;
  472. background-color: #fff;
  473. box-shadow: 0rpx 5rpx 10rpx 0rpx #0587e21c;
  474. border-radius: 20rpx;
  475. z-index: 99;
  476. position: relative;
  477. }
  478. .orderTitle {
  479. padding: 30rpx;
  480. border-bottom: 2rpx #f2f2f2 solid;
  481. }
  482. .orderTitleText {
  483. display: inline-block;
  484. vertical-align: middle;
  485. width: calc(100% - 200rpx);
  486. color: #000;
  487. font-size: 38rpx;
  488. font-weight: 600;
  489. overflow: hidden;
  490. white-space: nowrap;
  491. text-overflow: ellipsis;
  492. }
  493. .orderTitleMore {
  494. display: inline-block;
  495. vertical-align: middle;
  496. width: 200rpx;
  497. color: #777;
  498. font-size: 32rpx;
  499. text-align: right;
  500. }
  501. .orderContent {
  502. display: flex;
  503. justify-content: space-around;
  504. padding: 30rpx 0;
  505. }
  506. .orderContentItem {
  507. text-align: center;
  508. }
  509. .orderContentItemNum {
  510. display: block;
  511. font-size: 40rpx;
  512. font-weight: bold;
  513. color: #000;
  514. margin-bottom: 30rpx;
  515. }
  516. .orderContentItemTitle {
  517. display: block;
  518. font-size: 34rpx;
  519. color: #000;
  520. }
  521. .moreServiceBox {
  522. margin: 30rpx 20rpx;
  523. background-color: #fff;
  524. box-shadow: 0rpx 5rpx 10rpx 0rpx #0587e21c;
  525. border-radius: 20rpx;
  526. z-index: 99;
  527. position: relative;
  528. }
  529. .moreServiceTitle {
  530. padding: 40rpx 20rpx 20rpx;
  531. vertical-align: middle;
  532. color: #000;
  533. font-size: 38rpx;
  534. font-weight: 600;
  535. }
  536. .moreServiceContent {
  537. padding: 0 20rpx 20rpx;
  538. }
  539. .serviceContentItem {
  540. padding: 20rpx 0;
  541. }
  542. .serviceContentItem+.serviceContentItem {
  543. border-top: 2rpx #f2f2f2 solid;
  544. }
  545. .serviceContentItemImg {
  546. display: inline-block;
  547. width: 60rpx;
  548. height: 60rpx;
  549. vertical-align: middle;
  550. margin-right: 20rpx;
  551. }
  552. .serviceContentItemTitle {
  553. display: inline-block;
  554. vertical-align: middle;
  555. width: calc(100% - 120rpx);
  556. color: #000;
  557. font-size: 36rpx;
  558. }
  559. .serviceContentItemIcon {
  560. display: inline-block;
  561. width: 40rpx;
  562. height: 40rpx;
  563. vertical-align: middle;
  564. text-align: right;
  565. }
  566. /* 自定提示弹窗 */
  567. .popMask {
  568. position: fixed;
  569. left: 0;
  570. top: 0;
  571. right: 0;
  572. bottom: 0;
  573. /* #ifndef APP-NVUE */
  574. display: flex;
  575. /* #endif */
  576. justify-content: center;
  577. align-items: center;
  578. background-color: rgba(0, 0, 0, 0.2);
  579. line-height: 1 !important;
  580. z-index: 99;
  581. }
  582. .popContent {
  583. width: 80%;
  584. line-height: 1 !important;
  585. }
  586. .popTips {
  587. width: 100%;
  588. font-size: 44rpx;
  589. color: #333;
  590. font-weight: bold;
  591. text-align: center;
  592. padding: 30rpx 0;
  593. line-height: 1 !important;
  594. background-color: #fff;
  595. border-radius: 30rpx 30rpx 0 0;
  596. }
  597. .popImg {
  598. width: 100%;
  599. height: 600rpx;
  600. border-radius: 0 0 30rpx 30rpx;
  601. }
  602. .popClose {
  603. margin-top: 30rpx;
  604. width: 100rpx;
  605. height: 100rpx;
  606. margin-left: calc(50% - 50rpx);
  607. }
  608. .popBody {
  609. width: calc(100% - 40rpx);
  610. padding: 20rpx 20rpx 30rpx;
  611. font-size: 36rpx;
  612. color: #333;
  613. line-height: 1.5 !important;
  614. background-color: #fff;
  615. }
  616. .fway-form-input {
  617. display: block;
  618. height: 90rpx;
  619. line-height: 90rpx;
  620. width: calc(100% - 20rpx);
  621. text-align: center;
  622. padding: 0 10rpx;
  623. font-size: 36rpx;
  624. background-color: #f7f7f7;
  625. white-space: nowrap;
  626. overflow-y: hidden;
  627. border-radius: 10rpx;
  628. }
  629. .bindedTips {
  630. width: calc(100%);
  631. line-height: 40rpx;
  632. font-size: 36rpx;
  633. text-align: center;
  634. }
  635. .errorTips {
  636. width: calc(100%);
  637. line-height: 40rpx;
  638. padding: 30rpx 0 0;
  639. font-size: 32rpx;
  640. color: #d9001bfe;
  641. }
  642. .popBtnBox {
  643. width: 100%;
  644. display: flex;
  645. justify-content: space-between;
  646. padding: 10rpx 0;
  647. background-color: #fff;
  648. border-top: 2rpx #ebebeb solid;
  649. border-radius: 0 0 30rpx 30rpx;
  650. }
  651. .popBtn {
  652. width: 50%;
  653. padding: 20rpx 0;
  654. text-align: center;
  655. font-size: 36rpx;
  656. letter-spacing: 2rpx;
  657. line-height: 1 !important;
  658. }
  659. .popBtn+.popBtn {
  660. border-left: 2rpx #ebebeb solid;
  661. }
  662. .loginPopBtn{
  663. width: 90%;
  664. text-align: center;
  665. background-color: #07c160;
  666. color: #fff;
  667. font-size: 32rpx;
  668. border-radius: 50rpx;
  669. line-height: 2.5;
  670. margin-left: 5%;
  671. margin-bottom: 30rpx;
  672. }
  673. </style>