index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <view class="content">
  3. <!-- <top-title :titleValue="title" :btnTop="btnPos" style="width: 100%;"></top-title> -->
  4. <view class="self-inf" style="margin-top:40rpx">
  5. <view class="img-name-box" v-if="isAuth">
  6. <image :src="userHeadImg ? userHeadImg : '/static/auth-icon.png'" class="heade-img" mode="aspectFill"></image>
  7. <!-- <p class="nickname">{{ userNickName }}</p> -->
  8. <button @click="goWithHouse()" class="auth-btn">{{isWith ? '解除关联': '关联住房'}}</button>
  9. </view>
  10. <view class="house-info-box" v-if="isWith">
  11. <view>
  12. <text style="width: 160rpx;">住宅地址:</text>
  13. <text>{{houseInfo.address}}</text>
  14. </view>
  15. <view>
  16. <text style="width: 160rpx;">户主姓名:</text>
  17. <text>{{houseInfo.master}}</text>
  18. </view>
  19. <view>
  20. <text style="width: 160rpx;">住宅面积:</text>
  21. <text>{{houseInfo.area}}</text>
  22. </view>
  23. </view>
  24. <view class="img-name-box" v-if="!isAuth">
  25. <image src="/static/auth-icon.png" class="heade-img" mode="aspectFill"></image>
  26. <button @click="goAuthPage()" class="auth-btn">立即登录</button>
  27. </view>
  28. <!-- <image class="bg-img" :src="swiperBackground" mode="aspectFill"></image> -->
  29. <view class="bg-img"></view>
  30. <image src="../../static/Intersect.svg" class="groove-img"></image>
  31. </view>
  32. <view class="options">
  33. <view v-for="(item, idx) in list" :key="idx" class="options-item" @click="goDetailFn(idx, item.url)" v-if="item.isShow">
  34. <view class="img-box">
  35. <img :src="item.icoin" alt="" class="options-item-img" />
  36. </view>
  37. <view class="options-item-name">
  38. {{ item.name }}
  39. </view>
  40. </view>
  41. </view>
  42. <foot-tabs :selectedIndex='1'></foot-tabs>
  43. </view>
  44. </template>
  45. <script>
  46. import md5 from "@/common/md5.js";
  47. import footTabs from '@/components/foot-tabs/footTabs.vue';
  48. export default {
  49. components: {
  50. 'foot-tabs': footTabs,
  51. },
  52. data() {
  53. return {
  54. isAuth: true,
  55. userHeadImg: "",
  56. userNickName: "",
  57. btnPos:uni.getMenuButtonBoundingClientRect().top + 6,
  58. houseInfo:{
  59. address:'千林郡5号楼1单元10层1001室',
  60. master:'曹**',
  61. area:'108'
  62. },
  63. isWith:0,
  64. list: [
  65. {
  66. icoin: "/static/selfCenter/sign.png",
  67. name: "供暖订单" ,
  68. url: "/pages/heatingPage/list",
  69. isShow:true,
  70. },
  71. {
  72. icoin: "/static/selfCenter/suggest.png",
  73. name: "我的报修" ,
  74. url: "/pages/selfCenter/my_fix",
  75. isShow:true,
  76. },
  77. /*
  78. {
  79. icoin: "/static/selfCenter/back.png",
  80. name: "退出登录" ,
  81. isShow:true,
  82. }
  83. */
  84. ],
  85. swiperBackground: "/static/poster-bg.png",
  86. };
  87. },
  88. onLoad() {
  89. //this.getSwiperList();
  90. //this.$forceUpdate();
  91. },
  92. onShow() {
  93. this.isAuth = getApp().globalData.isAuth;
  94. if(this.isAuth){
  95. this.userHeadImg = getApp().globalData.user_headUrl;
  96. this.userNickName = getApp().globalData.user_name;
  97. }
  98. this.getUserInfo();
  99. },
  100. methods: {
  101. goAuthPage() {
  102. uni.navigateTo({
  103. url: "../auth/index",
  104. });
  105. },
  106. goWithHouse(){
  107. if (this.isWith == 0)
  108. {
  109. uni.navigateTo({
  110. url: "/pages/selfCenter/with_house",
  111. });
  112. return;
  113. }
  114. //解除绑定
  115. let md5Sign = md5(
  116. "method=" +
  117. "user" +
  118. "&timestamp=" +
  119. getApp().globalData.globalTimestamp +
  120. "&secret=" +
  121. getApp().globalData.secret
  122. );
  123. let url =
  124. getApp().globalData.shareUrl +
  125. "api/api.php" +
  126. "?method=user&action=unband_owner&timestamp=" +
  127. getApp().globalData.globalTimestamp +
  128. "&sign=" +
  129. md5Sign;
  130. uni.request({
  131. url: url,
  132. method: "POST",
  133. header: {
  134. "content-type": "application/x-www-form-urlencoded",
  135. },
  136. data: {
  137. openId: getApp().globalData.open_id,
  138. },
  139. success: (res) => {
  140. if (res.data.code === 200) {
  141. this.isWith = 0;
  142. this.houseInfo.address = "";
  143. this.houseInfo.master = "";
  144. this.houseInfo.area = "";
  145. uni.showToast({
  146. title: "已解除绑定",
  147. duration: 2500,
  148. icon: "none",
  149. });
  150. }
  151. },
  152. fail: () => {
  153. console.log("连接失败");
  154. },
  155. });
  156. },
  157. goDetailFn(index, url) {
  158. let that = this;
  159. if(!that.isAuth){
  160. uni.showToast({
  161. title: "您还没有登录授权",
  162. duration: 2500,
  163. icon: "none",
  164. });
  165. return;
  166. }
  167. switch (index) {
  168. case 0: //供暖订单
  169. uni.navigateTo({
  170. url,
  171. });
  172. break;
  173. case 1: //我的报修
  174. uni.navigateTo({
  175. url,
  176. });
  177. break;
  178. case 2: //退出登录
  179. uni.showModal({
  180. title: "确定退出登录吗?",
  181. success(res) {
  182. if (res.confirm) {
  183. that.loginOut();
  184. } else if (res.cancel) {
  185. console.log("用户点击取消");
  186. }
  187. },
  188. });
  189. break;
  190. }
  191. },
  192. loginOut() {
  193. let md5Sign = md5(
  194. "method=" +
  195. "user" +
  196. "&timestamp=" +
  197. getApp().globalData.globalTimestamp +
  198. "&secret=" +
  199. getApp().globalData.secret
  200. );
  201. let url =
  202. getApp().globalData.shareUrl +
  203. "api/api.php" +
  204. "?method=user&action=logout&timestamp=" +
  205. getApp().globalData.globalTimestamp +
  206. "&sign=" +
  207. md5Sign;
  208. uni.request({
  209. url: url,
  210. method: "POST",
  211. header: {
  212. "content-type": "application/x-www-form-urlencoded",
  213. },
  214. data: {
  215. openId: getApp().globalData.open_id,
  216. },
  217. success: (res) => {
  218. if (res.data.code === 200) {
  219. this.isAuth = false;
  220. getApp().globalData.isAuth = false;
  221. getApp().globalData.user_headUrl = "";
  222. getApp().globalData.user_name = "";
  223. getApp().globalData.user_phone = "";
  224. //this.list[2].isShow = false;
  225. //this.$forceUpdate();
  226. uni.showToast({
  227. title: "退出登录成功",
  228. duration: 2500,
  229. icon: "none",
  230. });
  231. }
  232. },
  233. fail: () => {
  234. console.log("连接失败");
  235. },
  236. });
  237. },
  238. getUserInfo() {
  239. let md5Sign = md5(
  240. "method=" +
  241. "user" +
  242. "&timestamp=" +
  243. getApp().globalData.globalTimestamp +
  244. "&secret=" +
  245. getApp().globalData.secret
  246. );
  247. let url =
  248. getApp().globalData.shareUrl +
  249. "api/api.php" +
  250. "?method=user&action=info_by_openid&timestamp=" +
  251. getApp().globalData.globalTimestamp +
  252. "&sign=" +
  253. md5Sign;
  254. uni.request({
  255. url: url,
  256. method: "POST",
  257. header: {
  258. "content-type": "application/x-www-form-urlencoded",
  259. },
  260. data: {
  261. openId: getApp().globalData.open_id,
  262. },
  263. success: (res) => {
  264. if (res.data.code === 200) {
  265. if (res.data.data.nickname) {
  266. this.isAuth = true;
  267. this.userHeadImg = res.data.data.headimg;
  268. this.userNickName = res.data.data.nickname;
  269. getApp().globalData.user_phone = res.data.data.phone;
  270. getApp().globalData.globalAuth = true;
  271. if(res.data.data.stat_user){
  272. this.list[3].isShow = true;
  273. }
  274. if (res.data.data.owner_info){
  275. let wi = res.data.data.owner_info;
  276. this.houseInfo.address = wi.estate_name + wi.building_name + wi.unit + wi.room;
  277. this.houseInfo.master = wi.owner_name;
  278. this.houseInfo.area = wi.area;
  279. this.isWith = 1;
  280. }
  281. } else {
  282. this.isAuth = false;
  283. getApp().globalData.globalAuth = false;
  284. }
  285. }
  286. },
  287. fail: () => {
  288. console.log("连接失败");
  289. },
  290. });
  291. },
  292. getSwiperList() {
  293. let md5Sign = md5(
  294. "method=" +
  295. "common" +
  296. "&timestamp=" +
  297. getApp().globalData.globalTimestamp +
  298. "&secret=" +
  299. getApp().globalData.secret
  300. );
  301. let url =
  302. getApp().globalData.shareUrl +
  303. "api/api.php" +
  304. "?method=common&source=main_pics&action=list&timestamp=" +
  305. getApp().globalData.globalTimestamp +
  306. "&sign=" +
  307. md5Sign;
  308. uni.request({
  309. url: url,
  310. method: "POST",
  311. header: {
  312. "content-type": "application/x-www-form-urlencoded",
  313. },
  314. data: {
  315. order_by: "weight desc",
  316. s_status: 1,
  317. },
  318. success: (res) => {
  319. if (res.data.code === 200) {
  320. // this.swiperBackground = getApp().globalData.shareUrl + res.data.data.list[0].pic_path;
  321. }
  322. },
  323. fail: () => {
  324. console.log("连接失败");
  325. },
  326. });
  327. },
  328. },
  329. };
  330. </script>
  331. <style lang="scss" scoped>
  332. .content {
  333. display: flex;
  334. flex-direction: column;
  335. .self-inf {
  336. position: relative;
  337. height: 440rpx;
  338. width: 100%;
  339. display: flex;
  340. margin-bottom: 80rpx;
  341. border-radius: 0rpx 0rpx 100% 100%;
  342. .img-name-box {
  343. height: 200rpx;
  344. margin-top: 120rpx;
  345. display: flex;
  346. align-items: center;
  347. z-index: 99999;
  348. flex-direction: column;
  349. justify-content: center;
  350. .auth-btn {
  351. margin-left: 30rpx;
  352. margin-top: 20rpx;
  353. font-size: 24rpx;
  354. background-color: #02a7f0;
  355. color: #fff;
  356. }
  357. .heade-img {
  358. z-index: 1;
  359. width: 100rpx;
  360. height: 100rpx;
  361. border-radius: 50%;
  362. margin-left: 40rpx;
  363. }
  364. }
  365. .house-info-box {
  366. display: flex;
  367. flex-direction: column;
  368. justify-content: space-evenly;
  369. width: 70%;
  370. height: 70%;
  371. margin-top: 80rpx;
  372. margin-left: 30rpx;
  373. view{
  374. display: flex;
  375. text {
  376. color: #fff;
  377. font-size: 28rpx;
  378. }
  379. }
  380. }
  381. .bg-img {
  382. z-index: -1;
  383. position: absolute;
  384. width: 100%;
  385. height: 100%;
  386. background-color: #02a7f0;
  387. // border-radius: 0rpx 0rpx 70rpx 70rpx;
  388. }
  389. .groove-img {
  390. width: 100%;
  391. height: 100rpx;
  392. bottom: -22rpx;
  393. position: absolute;
  394. }
  395. .nickname {
  396. font-weight: 600;
  397. font-size: 28rpx;
  398. margin-left: 30rpx;
  399. margin-top: 20rpx;
  400. color: #ffffff;
  401. letter-spacing: 1rpx;
  402. }
  403. }
  404. .options {
  405. padding: 70rpx;
  406. z-index: 99;
  407. position: relative;
  408. top: -160rpx;
  409. .options-item {
  410. background-color: #fff;
  411. display: flex;
  412. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  413. border-radius: 32rpx;
  414. margin-top: 20px;
  415. height: 150rpx;
  416. align-items: center;
  417. .img-box {
  418. margin-left: 40rpx;
  419. .options-item-img {
  420. width: 56rpx;
  421. height: 56rpx;
  422. }
  423. }
  424. .options-item-name {
  425. margin-left: 40rpx;
  426. font-weight: 600;
  427. font-size: 30rpx;
  428. margin-bottom: 10rpx;
  429. }
  430. }
  431. }
  432. }
  433. .fontGrey {
  434. color: $uni-text-color-grey;
  435. }
  436. </style>