租房小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

299 lines
9.2 KiB

9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
  1. <template>
  2. <view class="u-page">
  3. <!-- 已登录状态 -->
  4. <view v-if="isLoggedIn" class="se-pt-30 se-pb-60 se-px-40 se-bgc-green se-c-white se-pos">
  5. <view class="se-flex">
  6. <image @click="onHead" :src="userInfo.headImage" class="se-br-p-50 se-bgc-f9 se-w-120 se-h-120" mode="">
  7. </image>
  8. <view class="se-ml-20 se-flex se-flex-v-sa se-flex-ai-fs">
  9. <view class="se-flex" style="align-items: center;">
  10. <text class="se-fw-6 se-fs-30">{{userInfo.nickName?userInfo.nickName:'暂无昵称'}}</text>
  11. <!-- 会员状态 -->
  12. <view class="" v-if="vipInfo.title" style="display: flex;background-color: #fff;
  13. color: #0f0;
  14. font-size: 24rpx;
  15. align-items: center;
  16. border-radius: 20rpx;
  17. padding: 4rpx 10rpx;">
  18. {{vipInfo.title}}
  19. </view>
  20. </view>
  21. <view class="se-fs-24 se-display-ib" v-if="userInfo.phone">
  22. <text>手机号:</text>
  23. <text class="se-ml-20">{{userInfo.phone}}</text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 未登录状态 -->
  29. <view v-else class="se-pt-30 se-pb-60 se-px-40 se-bgc-green se-c-white se-pos">
  30. <view class="se-flex se-flex-v-c se-flex-h-c se-py-60">
  31. <view class="se-ta-c">
  32. <image class="se-w-120 se-h-120 se-br-p-50 se-bgc-f9" src="@/static/image/header.png" mode=""></image>
  33. <view class="se-mt-20 se-fs-30 se-fw-6">未登录</view>
  34. <view class="se-mt-10 se-fs-24">登录后享受更多服务</view>
  35. <view @click="goToLogin" class="se-mt-30 se-br-40 se-bgc-white se-c-green se-py-15 se-px-40 se-fs-28 se-fw-6">
  36. 立即登录
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <!-- <view class="se-pos-cb se-flex se-flex-h-sb se-w-vw-82 se-br-10 se-bgc-white se-py-30 se-px-20"
  42. style="bottom: -90rpx;">
  43. <view class="se-flex se-flex-v-c se-flex-1">
  44. <image src="@/static/image/46892@2x.png" class="se-a-80" mode=""></image>
  45. <view @click="onNavigateTo()" class=" se-ta-c se-fw-6 se-br-30 se-mt-10 se-py-5 se-px-22 se-c-black se-fs-22 ">
  46. 我的钱包
  47. </view>
  48. </view>
  49. <view class="se-flex se-flex-v-c se-flex-1 ">
  50. <image src="@/static/image/47077@2x.png" class="se-a-80" mode=""></image>
  51. <view @click="onNavigateTo()" class=" se-ta-c se-fw-6 se-br-30 se-mt-10 se-py-5 se-px-22 se-c-black se-fs-22 ">
  52. 我的预约
  53. </view>
  54. </view>
  55. <view class="se-flex se-flex-v-c se-flex-1 ">
  56. <image src="@/static/image/47065@2x.png" class="se-a-80" mode=""></image>
  57. <view @click="onNavigateTo()" class=" se-ta-c se-fw-6 se-br-30 se-mt-10 se-py-5 se-px-22 se-c-black se-fs-22 ">
  58. 我的收藏
  59. </view>
  60. </view>
  61. <view class="se-flex se-flex-v-c se-flex-1 ">
  62. <image src="@/static/image/46896@2x.png" class="se-a-80" mode=""></image>
  63. <view @click="onNavigateTo()" class=" se-ta-c se-fw-6 se-br-30 se-mt-10 se-py-5 se-px-22 se-c-black se-fs-22 ">
  64. 需求发布
  65. </view>
  66. </view>
  67. </view> -->
  68. <view class="se-m-30 se-mt-30 se-pl-30 se-pr-20 se-br-20 se-bgc-white">
  69. <!-- 需要登录的功能 -->
  70. <template v-if="isLoggedIn">
  71. <!-- <view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b" @click="onBrokerAccount">
  72. <view class="se-flex se-flex-ai-c">
  73. <image class="se-a-30" src="@/static/image/home4734.png" mode=""></image>
  74. <text class="se-ml-20 se-fs-24 se-fw-5">经纪人账号</text>
  75. </view>
  76. <view class="se-flex se-flex-ai-c">
  77. <uv-icon name="arrow-right"></uv-icon>
  78. </view>
  79. </view>
  80. <view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b" @click="onLandlord">
  81. <view class="se-flex se-flex-ai-c">
  82. <image class="se-a-30" src="@/static/image/home4734.png" mode=""></image>
  83. <text class="se-ml-20 se-fs-24 se-fw-5">房东中心</text>
  84. </view>
  85. <view class="se-flex se-flex-ai-c">
  86. <uv-icon name="arrow-right"></uv-icon>
  87. </view>
  88. </view>
  89. <view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b" @click="onBrokerCenter">
  90. <view class="se-flex se-flex-ai-c">
  91. <image class="se-a-30" src="@/static/image/47100.png" mode=""></image>
  92. <text class="se-ml-20 se-fs-24 se-fw-5">经纪人中心</text>
  93. </view>
  94. <view class="se-flex se-flex-ai-c">
  95. <uv-icon name="arrow-right"></uv-icon>
  96. </view>
  97. </view> -->
  98. </template>
  99. <!-- 需要登录的功能 -->
  100. <!-- <template v-if="isLoggedIn">
  101. <view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b" @click="onMyPublishedHouses">
  102. <view class="se-flex se-flex-ai-c">
  103. <image class="se-a-30" src="@/static/image/home4734.png" mode=""></image>
  104. <text class="se-ml-20 se-fs-24 se-fw-5">我发布的房源</text>
  105. </view>
  106. <view class="se-flex se-flex-ai-c">
  107. <uv-icon name="arrow-right"></uv-icon>
  108. </view>
  109. </view>
  110. </template> -->
  111. <!-- 通用功能 -->
  112. <view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b" @click="onCustomerService">
  113. <view class="se-flex se-flex-ai-c">
  114. <image class="se-a-30" src="@/static/image/user49384.png" mode=""></image>
  115. <text class="se-ml-20 se-fs-24 se-fw-5">在线客服</text>
  116. </view>
  117. <view class="se-flex se-flex-ai-c">
  118. <uv-icon name="arrow-right"></uv-icon>
  119. </view>
  120. </view>
  121. <view class="se-py-30 se-px-20 se-flex se-flex-h-sb" @click="onVersion">
  122. <view class="se-flex se-flex-ai-c">
  123. <image class="se-a-30" src="@/static/image/47186.png" mode=""></image>
  124. <text class="se-ml-20 se-fs-24 se-fw-5">关于我们</text>
  125. </view>
  126. <view class="se-flex se-flex-ai-c">
  127. <uv-icon name="arrow-right"></uv-icon>
  128. </view>
  129. </view>
  130. <!-- 退出登录按钮 - 仅登录时显示 -->
  131. <view v-if="isLoggedIn" class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-t" @click="onLogOut">
  132. <view class="se-flex se-flex-ai-c">
  133. <text class="se-fs-24 se-fw-5">退出登录</text>
  134. </view>
  135. <view class="se-flex se-flex-ai-c">
  136. <uv-icon name="arrow-right"></uv-icon>
  137. </view>
  138. </view>
  139. </view>
  140. </view>
  141. </template>
  142. <script>
  143. import configList from '@/mixins/configList.js'
  144. export default {
  145. mixins: [configList],
  146. data() {
  147. return {
  148. token: '',
  149. }
  150. },
  151. computed: {
  152. // 检查是否已登录
  153. isLoggedIn() {
  154. return this.token && this.token.length > 0
  155. }
  156. },
  157. onLoad() {
  158. this.checkLoginStatus()
  159. },
  160. onShow() {
  161. this.checkLoginStatus()
  162. if (this.isLoggedIn) {
  163. this.$store.commit('getUserInfo')
  164. }
  165. },
  166. methods: {
  167. // 检查登录状态
  168. checkLoginStatus() {
  169. this.token = uni.getStorageSync('token') || ''
  170. },
  171. // 去登录页面
  172. goToLogin() {
  173. uni.navigateTo({
  174. url: "/pages/auth/index"
  175. })
  176. },
  177. // 点击头像
  178. onHead() {
  179. if (!this.isLoggedIn) {
  180. this.goToLogin()
  181. return
  182. }
  183. uni.navigateTo({
  184. url: "/pages/login/index?back=" + 1
  185. })
  186. },
  187. // 需要登录验证的方法
  188. checkLoginAndNavigate(url, title = '该功能') {
  189. if (!this.isLoggedIn) {
  190. uni.showToast({
  191. title: title + '需要登录',
  192. icon: 'none'
  193. })
  194. setTimeout(() => {
  195. this.goToLogin()
  196. }, 1500)
  197. return
  198. }
  199. uni.navigateTo({
  200. url: url
  201. })
  202. },
  203. openMemberPage() {
  204. this.checkLoginAndNavigate("/pages_subpack/member/index", "会员中心")
  205. },
  206. onLandlord() {
  207. this.checkLoginAndNavigate("/pages_subpack/landlord-center/index", "房东中心")
  208. },
  209. onBrokerCenter() {
  210. this.checkLoginAndNavigate("/pages_subpack/broker-center/index", "经纪人中心")
  211. },
  212. onVersion() {
  213. uni.navigateTo({
  214. url: "/pages_subpack/version/index"
  215. })
  216. },
  217. onBrokerAccount() {
  218. this.checkLoginAndNavigate("/pages_subpack/broker-account/index", "经纪人账号")
  219. },
  220. // 我发布的房源
  221. onMyPublishedHouses() {
  222. this.checkLoginAndNavigate("/pages_subpack/my-published-houses/index", "我发布的房源")
  223. },
  224. onLogOut() {
  225. if (!this.isLoggedIn) {
  226. uni.showToast({
  227. title: '您还未登录',
  228. icon: 'none'
  229. })
  230. return
  231. }
  232. uni.showModal({
  233. title: "温馨提示",
  234. content: "确定退出当前登录",
  235. cancelText: "取消",
  236. confirmText: "确定",
  237. success: (res) => {
  238. console.info(res)
  239. if (res.confirm == true) {
  240. uni.removeStorageSync("userInfo")
  241. uni.removeStorageSync("token")
  242. uni.removeStorageSync("sessionKey")
  243. uni.removeStorageSync("vipInfo")
  244. // 清除本地状态
  245. this.token = ''
  246. this.userInfo = {}
  247. this.vipInfo = {}
  248. uni.showToast({
  249. title: '退出成功',
  250. icon: 'success'
  251. })
  252. // 可以选择跳转到登录页或刷新当前页
  253. // uni.navigateTo({
  254. // url: "/pages/auth/index"
  255. // })
  256. }
  257. }
  258. })
  259. },
  260. onCustomerService() {
  261. let that = this
  262. let obj = that.$utils.getkeyContent('phone')
  263. if (uni.canIUse('makePhoneCall')) {
  264. uni.makePhoneCall({
  265. phoneNumber: this.configList.phone, // 电话号码
  266. success: function() {
  267. console.log('拨打电话成功');
  268. },
  269. fail: function() {
  270. console.log('拨打电话失败');
  271. }
  272. });
  273. } else {
  274. console.log('你的设备不支持拨打电话功能');
  275. }
  276. }
  277. }
  278. }
  279. </script>
  280. <style>
  281. page {
  282. background-color: #f5f5f5 !important;
  283. }
  284. .se-grid {
  285. display: grid;
  286. grid-template-columns: 1fr 1fr 1fr 1fr;
  287. gap: 10rpx;
  288. padding-bottom: 4rpx;
  289. }
  290. </style>