index.vue 11 KB

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