Mine.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  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" v-if="openID" @tap="onGridmanRewardTo"> -->
  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. // uni.setStorageSync('userInfo', {
  270. // openID: objData.Openid,
  271. // // userImg: objData.img ? (that.$admin.config.sysweburl + objData.img) : '',
  272. // userName: objData.UserName || '',
  273. // userImg: '',
  274. // // userName: '',
  275. // userTel: objData.Phone || '',
  276. // userType: objData.UserType || '1', // 登录用户类型 1:市民 2:网格员
  277. // YQCode: objData.YQCode // 邀请码
  278. // })
  279. } else {
  280. that.$util.msg('登录失败,请稍后重试');
  281. }
  282. })
  283. } else {
  284. that.$util.msg('登录失败,请重新操作');
  285. }
  286. })
  287. })
  288. }else {
  289. that.$util.msg('请授权手机号登录');
  290. }
  291. },
  292. orderListTo(type) {
  293. if (!that.openID) {
  294. that.$util.msg("请先登录");
  295. return;
  296. }
  297. uni.navigateTo({
  298. url: '/pagesBase/Order/List?tabIndex=' + type
  299. })
  300. },
  301. onMyRewardTo() {
  302. if (!that.openID) {
  303. that.$util.msg("请先登录");
  304. return;
  305. }
  306. uni.navigateTo({
  307. // url: '/pagesBase/MyReward/Index'
  308. url: '/pagesBase/MyReward/Index_Temp'
  309. })
  310. },
  311. onGridmanRewardTo() {
  312. if (!that.openID) {
  313. that.$util.msg("请先登录");
  314. return;
  315. }
  316. uni.navigateTo({
  317. url: '/pagesBase/GridmanReward/Index'
  318. })
  319. },
  320. onInvitationTo() {
  321. if (!that.openID) {
  322. that.$util.msg("请先登录");
  323. return;
  324. }
  325. that.isInvitationPopShow = true;
  326. },
  327. onInvitationSubmitTo() {
  328. if (that.YQCode) {
  329. that.isInvitationPopShow = false;
  330. that.strYQCodeID = '';
  331. } else {
  332. if (that.$util.e_checkNumber(that.strYQCode) === false) {
  333. that.errorTips = '请输入正确的邀请码!';
  334. return;
  335. }
  336. if (that.strYQCode.length != 4) {
  337. that.errorTips = '请输入4位正确的邀请码!';
  338. return;
  339. }
  340. that.onInvitationSave();
  341. }
  342. },
  343. onInvitationSave() {
  344. that.$admin.req({
  345. method: 'PUT',
  346. url: '/api/v1/Snapshot/third/invitationcode',
  347. data: {
  348. invitationCode: that.strYQCode
  349. }
  350. }).then(res => {
  351. that.$util.msg('邀请码绑定成功!', function() {
  352. that.YQCode = that.strYQCode;
  353. that.errorTips = '';
  354. that.strYQCode = '';
  355. that.strYQCodeID = '';
  356. let objUser = uni.getStorageSync('userInfo');
  357. objUser.YQCode = that.YQCode;
  358. uni.setStorageSync('userInfo', objUser);
  359. });
  360. }, err => {
  361. that.errorTips = err;
  362. })
  363. },
  364. onInvitationCloseTo() {
  365. that.isInvitationPopShow = false;
  366. that.strYQCodeID = '';
  367. },
  368. onLoginCloseTo() {
  369. that.isLoginPopShow = false;
  370. that.strYQCodeID = '';
  371. },
  372. onGZHTo() {
  373. that.isPopShow = true;
  374. },
  375. onGZHCloseTo() {
  376. that.isPopShow = false;
  377. },
  378. loginOut() {
  379. if (that.openID) {
  380. uni.showModal({
  381. title: '退出登录',
  382. content: '确定要退出登录吗?',
  383. success(res) {
  384. if (res.confirm) {
  385. that.openID = '';
  386. that.userType = '1';
  387. that.userImg = '';
  388. that.userName = '';
  389. that.YQCode = '';
  390. that.rewardToday = -1;
  391. that.rewardHistory = -1;
  392. that.noResponseNum = -1;
  393. that.responsedNum = -1;
  394. that.evaluateNum = -1;
  395. // 清楚缓存
  396. uni.removeStorageSync('userInfo');
  397. }
  398. }
  399. })
  400. } else {
  401. that.$util.msg("请先登录");
  402. }
  403. }
  404. }
  405. }
  406. </script>
  407. <style lang="less">
  408. .container {
  409. background-color: #F6F7F8;
  410. height: 100vh;
  411. }
  412. .userInfoBox {
  413. height: 280rpx;
  414. width: 100%;
  415. background-color: #3e6ffd;
  416. }
  417. .userHeader {
  418. padding: 30rpx 30rpx 40rpx;
  419. font-size: 0;
  420. }
  421. .userImg {
  422. display: inline-block;
  423. width: 100rpx;
  424. height: 100rpx;
  425. vertical-align: middle;
  426. margin-right: 20rpx;
  427. border-radius: 10rpx;
  428. }
  429. .userNameBox {
  430. display: inline-block;
  431. width: calc(100% - 120rpx);
  432. vertical-align: middle;
  433. position: relative;
  434. border-radius: 50rpx;
  435. }
  436. .userName {
  437. width: calc(100%);
  438. vertical-align: middle;
  439. font-size: 28rpx;
  440. color: #fff;
  441. }
  442. .loginBtn {
  443. width: 230rpx;
  444. text-align: center;
  445. background-color: #07c160;
  446. color: #fff;
  447. font-size: 24rpx;
  448. border-radius: 50rpx;
  449. height: 50rpx;
  450. line-height: 50rpx;
  451. margin-left: 0;
  452. margin-top: 20rpx;
  453. }
  454. .userNumBox {
  455. display: flex;
  456. justify-content: space-around;
  457. }
  458. .userNumItem {
  459. text-align: center;
  460. }
  461. .userNum {
  462. display: block;
  463. font-size: 28rpx;
  464. color: #fff;
  465. margin-bottom: 20rpx;
  466. }
  467. .userNumTitle {
  468. display: block;
  469. font-size: 24rpx;
  470. color: #fff;
  471. }
  472. .userOrderBox {
  473. margin: 30rpx 20rpx;
  474. background-color: #fff;
  475. box-shadow: 0rpx 5rpx 10rpx 0rpx #0587e21c;
  476. border-radius: 20rpx;
  477. }
  478. .orderTitle {
  479. padding: 40rpx 20rpx 30rpx;
  480. border-bottom: 2rpx #f2f2f2 solid;
  481. }
  482. .orderTitleText {
  483. display: inline-block;
  484. vertical-align: middle;
  485. width: calc(100% - 160rpx);
  486. color: #333333;
  487. font-size: 30rpx;
  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: 160rpx;
  497. color: #999999;
  498. font-size: 22rpx;
  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: 32rpx;
  512. font-weight: bold;
  513. color: #000;
  514. margin-bottom: 30rpx;
  515. }
  516. .orderContentItemTitle {
  517. display: block;
  518. font-size: 24rpx;
  519. color: #333;
  520. }
  521. .moreServiceBox {
  522. margin: 30rpx 20rpx;
  523. background-color: #fff;
  524. box-shadow: 0rpx 5rpx 10rpx 0rpx #0587e21c;
  525. border-radius: 20rpx;
  526. }
  527. .moreServiceTitle {
  528. padding: 40rpx 20rpx 20rpx;
  529. vertical-align: middle;
  530. color: #333333;
  531. font-size: 30rpx;
  532. font-weight: 600;
  533. }
  534. .moreServiceContent {
  535. padding: 0 20rpx 20rpx;
  536. }
  537. .serviceContentItem {
  538. padding: 20rpx 0;
  539. }
  540. .serviceContentItem+.serviceContentItem {
  541. border-top: 2rpx #f2f2f2 solid;
  542. }
  543. .serviceContentItemImg {
  544. display: inline-block;
  545. width: 60rpx;
  546. height: 60rpx;
  547. vertical-align: middle;
  548. margin-right: 20rpx;
  549. }
  550. .serviceContentItemTitle {
  551. display: inline-block;
  552. vertical-align: middle;
  553. width: calc(100% - 110rpx);
  554. color: #333;
  555. font-size: 28rpx;
  556. }
  557. .serviceContentItemIcon {
  558. display: inline-block;
  559. width: 30rpx;
  560. height: 30rpx;
  561. vertical-align: middle;
  562. text-align: right;
  563. }
  564. /* 自定提示弹窗 */
  565. .popMask {
  566. position: fixed;
  567. left: 0;
  568. top: 0;
  569. right: 0;
  570. bottom: 0;
  571. /* #ifndef APP-NVUE */
  572. display: flex;
  573. /* #endif */
  574. justify-content: center;
  575. align-items: center;
  576. background-color: rgba(0, 0, 0, 0.2);
  577. line-height: 1 !important;
  578. z-index: 99;
  579. }
  580. .popContent {
  581. width: 80%;
  582. line-height: 1 !important;
  583. }
  584. .popTips {
  585. width: 100%;
  586. font-size: 36rpx;
  587. color: #333;
  588. font-weight: bold;
  589. text-align: center;
  590. padding: 30rpx 0;
  591. line-height: 1 !important;
  592. background-color: #fff;
  593. border-radius: 30rpx 30rpx 0 0;
  594. }
  595. .popImg {
  596. width: 100%;
  597. height: 600rpx;
  598. border-radius: 0 0 30rpx 30rpx;
  599. }
  600. .popClose {
  601. margin-top: 30rpx;
  602. width: 80rpx;
  603. height: 80rpx;
  604. margin-left: calc(50% - 40rpx);
  605. }
  606. .popBody {
  607. width: calc(100% - 40rpx);
  608. padding: 20rpx 20rpx 30rpx;
  609. font-size: 32rpx;
  610. color: #333;
  611. line-height: 1.5 !important;
  612. background-color: #fff;
  613. }
  614. .fway-form-input {
  615. display: block;
  616. height: 66rpx;
  617. line-height: 66rpx;
  618. width: calc(100% - 20rpx);
  619. text-align: center;
  620. padding: 0 10rpx;
  621. font-size: 28rpx;
  622. background-color: #f7f7f7;
  623. white-space: nowrap;
  624. overflow-y: hidden;
  625. border-radius: 10rpx;
  626. }
  627. .bindedTips {
  628. width: calc(100%);
  629. line-height: 40rpx;
  630. font-size: 28rpx;
  631. text-align: center;
  632. }
  633. .errorTips {
  634. width: calc(100%);
  635. line-height: 40rpx;
  636. padding: 10rpx 0 0;
  637. font-size: 24rpx;
  638. color: #d9001bfe;
  639. }
  640. .popBtnBox {
  641. width: 100%;
  642. display: flex;
  643. justify-content: space-between;
  644. padding: 10rpx 0;
  645. background-color: #fff;
  646. border-top: 2rpx #ebebeb solid;
  647. border-radius: 0 0 30rpx 30rpx;
  648. }
  649. .popBtn {
  650. width: 50%;
  651. padding: 20rpx 0;
  652. text-align: center;
  653. font-size: 30rpx;
  654. letter-spacing: 2rpx;
  655. line-height: 1 !important;
  656. }
  657. .popBtn+.popBtn {
  658. border-left: 2rpx #ebebeb solid;
  659. }
  660. .loginPopBtn{
  661. width: 90%;
  662. text-align: center;
  663. background-color: #07c160;
  664. color: #fff;
  665. font-size: 28rpx;
  666. border-radius: 50rpx;
  667. line-height: 2.5;
  668. margin-left: 5%;
  669. margin-bottom: 30rpx;
  670. }
  671. </style>