租房小程序前端代码
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.

282 lines
8.5 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. <view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b" @click="onCustomerService">
  101. <view class="se-flex se-flex-ai-c">
  102. <image class="se-a-30" src="@/static/image/user49384.png" mode=""></image>
  103. <text class="se-ml-20 se-fs-24 se-fw-5">在线客服</text>
  104. </view>
  105. <view class="se-flex se-flex-ai-c">
  106. <uv-icon name="arrow-right"></uv-icon>
  107. </view>
  108. </view>
  109. <view class="se-py-30 se-px-20 se-flex se-flex-h-sb" @click="onVersion">
  110. <view class="se-flex se-flex-ai-c">
  111. <image class="se-a-30" src="@/static/image/47186.png" mode=""></image>
  112. <text class="se-ml-20 se-fs-24 se-fw-5">关于我们</text>
  113. </view>
  114. <view class="se-flex se-flex-ai-c">
  115. <uv-icon name="arrow-right"></uv-icon>
  116. </view>
  117. </view>
  118. <!-- 退出登录按钮 - 仅登录时显示 -->
  119. <view v-if="isLoggedIn" class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-t" @click="onLogOut">
  120. <view class="se-flex se-flex-ai-c">
  121. <text class="se-fs-24 se-fw-5">退出登录</text>
  122. </view>
  123. <view class="se-flex se-flex-ai-c">
  124. <uv-icon name="arrow-right"></uv-icon>
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. </template>
  130. <script>
  131. import configList from '@/mixins/configList.js'
  132. export default {
  133. mixins: [configList],
  134. data() {
  135. return {
  136. token: '',
  137. }
  138. },
  139. computed: {
  140. // 检查是否已登录
  141. isLoggedIn() {
  142. return this.token && this.token.length > 0
  143. }
  144. },
  145. onLoad() {
  146. this.checkLoginStatus()
  147. },
  148. onShow() {
  149. this.checkLoginStatus()
  150. if (this.isLoggedIn) {
  151. this.$store.commit('getUserInfo')
  152. }
  153. },
  154. methods: {
  155. // 检查登录状态
  156. checkLoginStatus() {
  157. this.token = uni.getStorageSync('token') || ''
  158. },
  159. // 去登录页面
  160. goToLogin() {
  161. uni.navigateTo({
  162. url: "/pages/auth/index"
  163. })
  164. },
  165. // 点击头像
  166. onHead() {
  167. if (!this.isLoggedIn) {
  168. this.goToLogin()
  169. return
  170. }
  171. uni.navigateTo({
  172. url: "/pages/login/index?back=" + 1
  173. })
  174. },
  175. // 需要登录验证的方法
  176. checkLoginAndNavigate(url, title = '该功能') {
  177. if (!this.isLoggedIn) {
  178. uni.showToast({
  179. title: title + '需要登录',
  180. icon: 'none'
  181. })
  182. setTimeout(() => {
  183. this.goToLogin()
  184. }, 1500)
  185. return
  186. }
  187. uni.navigateTo({
  188. url: url
  189. })
  190. },
  191. openMemberPage() {
  192. this.checkLoginAndNavigate("/pages_subpack/member/index", "会员中心")
  193. },
  194. onLandlord() {
  195. this.checkLoginAndNavigate("/pages_subpack/landlord-center/index", "房东中心")
  196. },
  197. onBrokerCenter() {
  198. this.checkLoginAndNavigate("/pages_subpack/broker-center/index", "经纪人中心")
  199. },
  200. onVersion() {
  201. uni.navigateTo({
  202. url: "/pages_subpack/version/index"
  203. })
  204. },
  205. onBrokerAccount() {
  206. this.checkLoginAndNavigate("/pages_subpack/broker-account/index", "经纪人账号")
  207. },
  208. onLogOut() {
  209. if (!this.isLoggedIn) {
  210. uni.showToast({
  211. title: '您还未登录',
  212. icon: 'none'
  213. })
  214. return
  215. }
  216. uni.showModal({
  217. title: "温馨提示",
  218. content: "确定退出当前登录",
  219. cancelText: "取消",
  220. confirmText: "确定",
  221. success: (res) => {
  222. console.info(res)
  223. if (res.confirm == true) {
  224. uni.removeStorageSync("userInfo")
  225. uni.removeStorageSync("token")
  226. uni.removeStorageSync("sessionKey")
  227. uni.removeStorageSync("vipInfo")
  228. // 清除本地状态
  229. this.token = ''
  230. this.userInfo = {}
  231. this.vipInfo = {}
  232. uni.showToast({
  233. title: '退出成功',
  234. icon: 'success'
  235. })
  236. // 可以选择跳转到登录页或刷新当前页
  237. // uni.navigateTo({
  238. // url: "/pages/auth/index"
  239. // })
  240. }
  241. }
  242. })
  243. },
  244. onCustomerService() {
  245. let that = this
  246. let obj = that.$utils.getkeyContent('phone')
  247. if (uni.canIUse('makePhoneCall')) {
  248. uni.makePhoneCall({
  249. phoneNumber: this.configList.phone, // 电话号码
  250. success: function() {
  251. console.log('拨打电话成功');
  252. },
  253. fail: function() {
  254. console.log('拨打电话失败');
  255. }
  256. });
  257. } else {
  258. console.log('你的设备不支持拨打电话功能');
  259. }
  260. }
  261. }
  262. }
  263. </script>
  264. <style>
  265. page {
  266. background-color: #f5f5f5 !important;
  267. }
  268. .se-grid {
  269. display: grid;
  270. grid-template-columns: 1fr 1fr 1fr 1fr;
  271. gap: 10rpx;
  272. padding-bottom: 4rpx;
  273. }
  274. </style>