gemercheung 2 years ago
parent
commit
69ae86c70e

+ 25 - 4
miniprogram/api/fetchRoom.ts

@@ -3,12 +3,33 @@
 import { GET_ROOM } from '../utils/apiList'
 import { request, Response } from '../utils/http'
 
+interface RoomDetailType {
+  createTime: string
+  isShow: number
+  lastLookTime: string
+  roomCoverUrl: string
+  roomHostCode: string
+  roomHostName: string
+  roomId: string
+  roomInfo: string
+  roomShareCode: string
+  roomShareUrl: string
+  roomStatus: number
+  roomTitle: string
+  roomUserName: string
+  roomViewCount: number
+  sceneData: any[]
+  tbStatus: number
+  updateTime: string
+}
+type RoomDetailRes = Response & {
+  data: RoomDetailType
+}
+export const fetchRoom = async (roomId: string): Promise<RoomDetailType> => {
 
-export const fetchRoom = async (roomId: string) => {
-
-  const res = await request.get(GET_ROOM, {
+  const res = await request.get<RoomDetailRes>(GET_ROOM, {
     roomId: roomId
   })
-  console.log('res', res)
+  return res.data
 
 }

+ 0 - 1
miniprogram/api/index.ts

@@ -1 +0,0 @@
-export * from './fetchRoom'

+ 19 - 0
miniprogram/api/login.ts

@@ -0,0 +1,19 @@
+
+
+import { WX_LOGIN } from '../utils/apiList'
+import { request, Response } from '../utils/http'
+
+interface LoginResType {
+  token: string
+}
+type RoomDetailRes = Response & {
+  data: LoginResType
+}
+export const Login = async (code: string): Promise<LoginResType> => {
+
+  const res = await request.get<RoomDetailRes>(WX_LOGIN, {
+    code
+  })
+  return res.data
+
+}

+ 19 - 0
miniprogram/api/roomList.ts

@@ -0,0 +1,19 @@
+
+
+import { WX_LOGIN } from '../utils/apiList'
+import { request, Response } from '../utils/http'
+
+interface LoginResType {
+  token: string
+}
+type RoomDetailRes = Response & {
+  data: LoginResType
+}
+export const login = async (code: string): Promise<LoginResType> => {
+
+  const res = await request.get<RoomDetailRes>(WX_LOGIN, {
+    code
+  })
+  return res.data
+
+}

+ 36 - 0
miniprogram/api/user.ts

@@ -0,0 +1,36 @@
+
+
+import { WX_GET_PHONE, WX_GET_USER } from '../utils/apiList'
+import { request, Response } from '../utils/http'
+interface PhoneParams {
+  code: string
+  encryptedData: string
+  iv: string
+}
+
+interface PhoneResType {
+  countryCode: string
+  phoneNumber: string
+  purePhoneNumber: string
+}
+interface UserResType {
+
+}
+type UserRes = Response & {
+  data: PhoneRes
+}
+
+type PhoneRes = Response & {
+  data: PhoneResType
+}
+export const getUserInfo = async (): Promise<UserResType> => {
+
+  const res = await request.get<UserRes>(WX_GET_USER)
+  return res.data
+
+}
+
+export const decrptPhone = async (params: PhoneParams): Promise<PhoneResType> => {
+  const res = await request.get<PhoneRes>(WX_GET_PHONE, params)
+  return res.data
+}

+ 6 - 1
miniprogram/app.ts

@@ -37,10 +37,15 @@ App<IAppOption>({
   },
   setVoiceProps(props: VoiceProps) {
     Object.keys(props).forEach((k: string) => {
-      (voiceProps as any)[k] =  (props as any)[k]
+      (voiceProps as any)[k] = (props as any)[k]
     })
     voiceCbs.forEach((cb: Function) => cb(props))
   },
+  async setLogin(status: boolean): Promise<boolean> {
+    this.globalData.isLogin = status
+    return Promise.resolve(this.globalData.isLogin)
+
+  },
   onLaunch() {
     // 展示本地存储能力
     const logs = wx.getStorageSync('logs') || []

+ 4 - 1
miniprogram/pages/about/about.json

@@ -1,4 +1,7 @@
 {
   "navigationBarTitleText": "关于我们",
-  "usingComponents": {}
+  "enablePullDownRefresh": false,
+  "usingComponents": {
+    "t-divider": "tdesign-miniprogram/divider/divider"
+  }
 }

+ 61 - 1
miniprogram/pages/about/about.scss

@@ -1 +1,61 @@
-/* pages/about/about.wxss */
+/* pages/about/about.wxss */
+.about_container {
+  width: 100vw;
+  height: 100vh;
+
+  .inner {
+    width: calc(100% - 100rpx);
+    height: 100%;
+    display: flex;
+    flex-direction: column;
+    justify-content: space-between;
+    padding: 0 50rpx;
+  }
+
+  .logo {
+    width: 250rpx;
+    display: flex;
+    flex-direction: column;
+    align-items: flex-start;
+    margin: 220rpx auto 0 auto;
+
+    .logo-1 {
+      width: 250rpx;
+      height: 250rpx;
+      display: block;
+    }
+
+    .logo-2 {
+      width: 250rpx;
+      height: 60rpx;
+      display: block;
+      margin: 40rpx 0;
+    }
+
+    .logo-3 {
+      font-size: 40rpx;
+      text-align: center;
+      margin: 0 auto;
+    }
+  }
+
+  .info {
+    margin-bottom: 150rpx;
+    text-align: center;
+
+    .hero {
+      font-size: 32rpx;
+      display: block;
+      margin-bottom: 20rpx;
+    }
+
+    .sub,
+    .version {
+      color: #A3A4A5;
+      display: block;
+      margin-bottom: 20rpx;
+      font-size: 26rpx;
+    }
+  }
+
+}

+ 20 - 1
miniprogram/pages/about/about.wxml

@@ -1,2 +1,21 @@
 <!--pages/about/about.wxml-->
-<text>关于我们</text>
+<view class="about_container">
+  <view class="inner">
+    <view class="logo">
+      <image class="logo-1" src="../../static/images/logo1.png" mode="aspectFit" />
+      <image class="logo-2" src="../../static/images/logo2.png" mode="aspectFit" />
+      <text class="logo-3">LI-Stream</text>
+    </view>
+    <view class="info">
+      <text class="hero">四维带看是一款全新概念的VR远程营销利器,可通过VR场景,视频,图片,文字等同屏互动和重点标记的形式帮助商家/经纪人实现远程销售。</text>
+      <text class="sub">官方网站:www.4dkankan.com</text>
+      <text class="sub">客服电话:0756-6996790-800</text>
+      <t-divider />
+      <text class="version">版本号:1.0.2</text>
+    </view>
+
+
+  </view>
+
+
+</view>

+ 1 - 1
miniprogram/pages/index/index.wxml

@@ -1,6 +1,6 @@
 <!--index.wxml-->
 <view class="wrapper">
-  <t-sticky offset-top="{{0 }}">
+  <t-sticky offset-top="{{0}}">
     <view class="search-container">
       <t-search class="search" model:value="{{searchValue}}" label="1" placeholder="搜索带看" shape='round' />
     </view>

+ 4 - 1
miniprogram/pages/mp/mp.json

@@ -1,4 +1,7 @@
 {
   "navigationBarTitleText": "关注公众号",
-  "usingComponents": {}
+  "enablePullDownRefresh": false,
+  "usingComponents": {
+    "t-action-sheet": "tdesign-miniprogram/action-sheet/action-sheet"
+  }
 }

+ 21 - 2
miniprogram/pages/mp/mp.scss

@@ -1,5 +1,24 @@
 /* pages/mp/mp.wxss */
-.top {
-  width: 100%;
+
+.mp_container {
+  width: 100vw;
+  height: 100vh;
   display: block;
+  position: relative;
+}
+
+.background {
+  width: 100%;
+  height: 100%;
+
+}
+
+.qrcode {
+  // background-color: yellow;
+  width: 300rpx;
+  height: 300rpx;
+  position: absolute;
+  top: 32%;
+  left: 50%;
+  transform: translateX(-50%)
 }

+ 60 - 1
miniprogram/pages/mp/mp.ts

@@ -1,18 +1,77 @@
 // pages/mp/mp.ts
-Page({
+import ActionSheet, { ActionSheetTheme, ActionSheetShowOption } from 'tdesign-miniprogram/action-sheet/index';
+
+
 
+
+Page({
   /**
    * 页面的初始数据
    */
   data: {
+    pageImage: 'https://4dkk.4dage.com/miniapp-source/daikan/about_us.png',
+    pageQRcode: 'https://4dkk.4dage.com/miniapp-source/daikan/about_qrcode.png',
+    handler: null,
 
   },
+  handleActionShow() {
+    const basicListOption: ActionSheetShowOption = {
+      theme: ActionSheetTheme.List,
+      selector: '#t-action-sheet',
+      items: [
+        {
+          label: '下载图片',
+        },
+
+      ],
+    };
+    const handler = ActionSheet.show(basicListOption);
+    this.setData({
+      handler: handler
+    })
+  },
 
+  handleSelected(event: WechatMiniprogram.TouchEvent) {
+    const { index } = event.detail
+    console.log('event', index)
+    if (index === 0) {
+      wx.downloadFile({
+        url: this.data.pageQRcode,
+        success (res) {
+         wx.saveImageToPhotosAlbum({
+          filePath: res.tempFilePath,
+          success(res) {
+            wx.showModal({
+              title: '图片保存成功',
+              content: '图片成功保存到相册了,通过扫一扫就可以哒!',
+              showCancel: false,
+              confirmText: '好哒',
+              confirmColor: '#72B9C3',
+              success: (res) => {
+                if (res.confirm) {
+                }
+              }
+            })
+          }
+        })
+        }
+      })
+
+
+    }
+  },
+  handleCancel() {
+    const { handler } = this.data
+    if (handler) {
+      (handler as any).close()
+    }
+  },
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad() {
 
+
   },
 
   /**

+ 6 - 4
miniprogram/pages/mp/mp.wxml

@@ -1,7 +1,9 @@
 <!--pages/mp/mp.wxml-->
-<view>
-  <image class="top" src="../../static//images/about_bg.png" mode="aspectFit" />
-  <view class="qrcode">
-  </view>
+<view class="mp_container">
+  <!-- <image class="top" src="../../static//images/about_bg.png" mode="aspectFit" /> -->
 
+  <image class='background' src="{{pageImage}}" mode="aspectFit"/>
+  <view class="qrcode" bindtap="handleActionShow">
+  </view>
+  <t-action-sheet id="t-action-sheet" bind:selected="handleSelected"  bind:cancel="handleCancel"/>
 </view>

+ 1 - 0
miniprogram/pages/my/my.scss

@@ -35,6 +35,7 @@
   .personal-info {
     display: flex;
     flex-direction: column;
+    color: white;
 
     .title {
       font-size: 36rpx;

+ 21 - 0
miniprogram/pages/my/my.ts

@@ -1,4 +1,5 @@
 // pages/my/my.ts
+import { Login } from '../../api/login'
 
 Page({
 
@@ -29,6 +30,26 @@ Page({
    */
   onShow() {
     this.getTabBar().init();
+    const app = getApp<IAppOption>();
+    const isLogin = wx.getStorageSync('isLogin')
+    if (!isLogin) {
+      wx.login({
+        success: async function (res) {
+          if (res.code) {
+            const code = res.code
+            const result = await Login(code)
+            if (result.token) {
+              app.setLogin(true)
+              wx.setStorageSync('token', result.token)
+              wx.setStorageSync('isLogin', true)
+            }
+            console.log('result', result)
+          }
+        }
+      });
+    }
+
+
   },
   /**
    * 生命周期函数--监听页面隐藏

+ 1 - 1
miniprogram/pages/my/my.wxml

@@ -16,7 +16,7 @@
       <t-icon name="root-list" color="#ed7b2f" slot="left-icon" />
     </t-cell>
     <t-cell title="关注公众号" url="/pages/mp/mp" jump-type="navigateTo" note="获取最新资讯,咨询" arrow>
-      <t-icon name="chart-bubble" color="#ed7b2f" slot="left-icon" />
+      <t-icon name="logo-wechat" color="#ed7b2f" slot="left-icon" />
     </t-cell>
     <t-cell title="客服电话" note="400-669-8025" arrow>
       <t-icon name="call" color="#ed7b2f" slot="left-icon" />

+ 3 - 1
miniprogram/pages/personal/personal.json

@@ -4,6 +4,8 @@
   "usingComponents": {
     "t-cell": "tdesign-miniprogram/cell/cell",
     "t-avatar": "tdesign-miniprogram/avatar/avatar",
-    "t-button": "tdesign-miniprogram/button/button"
+    "t-button": "tdesign-miniprogram/button/button",
+    "t-input": "tdesign-miniprogram/input/input",
+    "t-action-sheet": "tdesign-miniprogram/action-sheet/action-sheet"
   }
 }

+ 23 - 1
miniprogram/pages/personal/personal.scss

@@ -4,9 +4,31 @@
   width: 100%;
   min-height: 100vh;
 }
-.btn-container{
+
+.btn-container {
   margin-top: 20rpx;
 }
+
 .btn {
   --td-button-default-bg-color: #ffffff;
+  --td-button-default-color: #FA5555;
+}
+
+.phone {
+  --td-button-default-color: #rgba(0, 0, 0, 0.4);
+  --td-button-font-weight: 300;
+
+  .t-button {
+    padding: 0;
+  }
+}
+
+.nickname {
+
+  .t-input__control {
+    text-align: right;
+  }
+  .t-input{
+    padding: 0;
+  }
 }

+ 57 - 11
miniprogram/pages/personal/personal.ts

@@ -1,4 +1,8 @@
 // pages/personal/personal.ts
+import ActionSheet, { ActionSheetTheme, ActionSheetShowOption } from 'tdesign-miniprogram/action-sheet/index';
+import { decrptPhone } from '../../api/user'
+
+const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
 Page({
 
   /**
@@ -26,7 +30,10 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow() {
-
+    const app = getApp<IAppOption>()
+    this.setData({
+      isLogin: app.globalData.isLogin
+    })
   },
 
   /**
@@ -63,17 +70,56 @@ Page({
   onShareAppMessage() {
 
   },
-  handleGetPhoneNumber(event: WechatMiniprogram.ButtonGetPhoneNumber) {
+  async checkSession(): Promise<boolean> {
+    let isExist = false
+    wx.checkSession({
+      success() {
+        isExist = true
+      },
+      fail() {
+        isExist = false
+      }
+    })
+    await sleep(1000)
+    return Promise.resolve(isExist)
+
+  },
+  async handleGetPhoneNumber(event: WechatMiniprogram.ButtonGetPhoneNumber) {
     // debugger
     console.log('event', event)
-    // wx.checkSession({
-    //   success(res) {
-    //     console.log(res, '登录状态')
-    //     //session_key 未过期,并且在本生命周期一直有效
-    //   },
-    //   fail(err) {
-    //     console.log(err)
-    //   }
-    // })
+    const isValid = await this.checkSession();
+    console.log('isValid', isValid)
+    if (isValid) {
+      const { code, iv, encryptedData } = event.detail
+      if (code && iv && encryptedData) {
+        const res = await decrptPhone({
+          iv: iv,
+          code: code,
+          encryptedData: encryptedData
+        })
+        console.log('res', res.phoneNumber)
+      }
+    }
+  },
+  handleSexSelectShow() {
+    const basicListOption: ActionSheetShowOption = {
+      theme: ActionSheetTheme.List,
+      selector: '#t-action-sheet',
+      items: [
+        {
+          label: '男性',
+        },
+        {
+          label: '女性',
+        },
+
+      ],
+    };
+    const handler = ActionSheet.show(basicListOption);
+  },
+  handleSelected(event: WechatMiniprogram.TouchEvent) {
+    console.log('event', event)
+    const { index } = event.detail
+
   }
 })

+ 6 - 7
miniprogram/pages/personal/personal.wxml

@@ -6,22 +6,21 @@
     </view>
   </t-cell>
 
-  <t-cell title="昵称" hover note="辅助信息" arrow>
+  <t-cell title="昵称" hover arrow>
+    <t-input type='nickname' class="nickname" placeholder="请输入昵称" slot='note'></t-input>
   </t-cell>
 
-
-  <t-cell title="性别" hover note="女" arrow>
+  <t-cell title="性别" hover note="女" arrow bind:click="handleSexSelectShow">
   </t-cell>
 
   <t-cell title="绑定手机" hover arrow>
     <view slot='note'>
-    <text>13631262857</text>
-      <!-- <t-button variant="text" size="small" open-type="getPhoneNumber" bindgetphonenumber="handleGetPhoneNumber"></t-button> -->
+      <!-- <text>13631262857</text> -->
+      <t-button class="phone" variant="text" size="small" open-type="getPhoneNumber" bindgetphonenumber="handleGetPhoneNumber">点击绑定</t-button>
     </view>
   </t-cell>
   <view class="btn-container">
     <t-button block size="large" class="btn">退出登录</t-button>
   </view>
-
-
+  <t-action-sheet id="t-action-sheet" bind:selected="handleSelected"  bind:cancel="handleCancel"/>
 </view>

+ 3 - 2
miniprogram/pages/room/room.ts

@@ -12,10 +12,11 @@ Page({
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad(options: { roomId: string }) {
+  async onLoad(options: { roomId: string }) {
     console.log('options', options)
     if (options.roomId) {
-      fetchRoom(options.roomId);
+      const res = await fetchRoom(options.roomId);
+      console.log('data', res)
     }
   },
 

+ 5 - 1
miniprogram/utils/apiList.ts

@@ -1,4 +1,8 @@
 export const GET_ROOM_LIST = '/takelook/roomList'
 export const GET_ROOM = '/takelook/roomInfo'
 export const GET_SIG = '/takelook/tencentYun/getSign'
-export const LEAVE_ROOM = '/takelook/inOrOutRoom'
+export const LEAVE_ROOM = '/takelook/inOrOutRoom'
+export const WX_LOGIN = '/takelook/wxApi/wxLogin'
+export const WX_GET_PHONE = '/takelook/wxApi/getPhone'
+export const WX_UPDATE_USER = '/takelook/wxApi/updateUser'
+export const WX_GET_USER = '/takelook/wxApi/updateUser'

+ 2 - 1
miniprogram/utils/http.ts

@@ -8,7 +8,8 @@ setConfig('baseURL', 'https://v4-test.4dkankan.com');
 
 REQUEST.Defaults.transformSend = async (options) => {
   // const token = await getAuthTokenPromise(); // 异步方法
-  // options.headers["Authorization"] = `brearer ${token}`;
+  const token = wx.getStorageSync('token') || '';
+    (options as any).headers['token'] = token;
   return transformRequestSendDefault(options);
 };
 

+ 1 - 0
typings/index.d.ts

@@ -20,4 +20,5 @@ interface IAppOption {
   addVoicePropsListener?: (cb: Function) => void
   removeVoicePropsListener?: (cb: Function) => void
   setVoiceProps?: (param: VoiceProps) => void
+  setLogin: (status: boolean) => Promise<boolean>
 }