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