浏览代码

静态页面

xcx 4 年前
父节点
当前提交
917084b212

+ 12
- 0
src/pages/WoDe/TuiJianErWeiMa/index.css 查看文件

@@ -5,3 +5,15 @@
5 5
   background: #f8f8f8;
6 6
   overflow: hidden;
7 7
 }
8
+.TuiJianErWeiMa > image {
9
+  width: 100%;
10
+  display: block;
11
+  position: relative;
12
+  z-index: 1;
13
+}
14
+.TuiJianErWeiMa > image.QrCodeImg {
15
+  position: absolute;
16
+  z-index: 2;
17
+  width: 50%;
18
+  height: auto;
19
+}

+ 14
- 2
src/pages/WoDe/TuiJianErWeiMa/index.jsx 查看文件

@@ -1,18 +1,30 @@
1
-import React, { useState } from 'react'
1
+import React, { useState, useEffect } from 'react'
2 2
 import Taro from '@tarojs/taro'
3 3
 import CustomHeader from '@/components/CustomHeader/index'
4
+import { getQrCodeImage, getCardQrParam } from '@/utils/qrcode'
4 5
 import Page from '@/layouts'
6
+import { useModel } from '@/store'
5 7
 import '@/assets/css/reset.less'
6 8
 import '@/assets/css/iconfont.less'
7 9
 import './index.less'
8 10
 
9
-export default function TuiJianErWeiMa (props) {
11
+export default function TuiJianErWeiMa () {
12
+
13
+  const { user } = useModel('user')
14
+  const [QrCodeImg, setQrCodeImg] = useState(null)
15
+
16
+  useEffect(() => {
17
+    if (QrCodeImg === null) {
18
+      setQrCodeImg(getQrCodeImage(getCardQrParam(user)))
19
+    }
20
+  }, [QrCodeImg])
10 21
 
11 22
   return (
12 23
     <Page>
13 24
       <view className='TuiJianErWeiMa'>
14 25
         <CustomHeader IsFixed={true} BgColor='none' Title='推荐二维码'></CustomHeader>
15 26
         <image mode='widthFix' src='https://zhiyun-image.oss-cn-shanghai.aliyuncs.com/xiangsong/img2.jpg'></image>
27
+        <image mode='widthFix' className='QrCodeImg' src={QrCodeImg}></image>
16 28
       </view>
17 29
     </Page>
18 30
   )

+ 7
- 0
src/pages/WoDe/TuiJianErWeiMa/index.less 查看文件

@@ -10,5 +10,12 @@
10 10
     display: block;
11 11
     position: relative;
12 12
     z-index: 1;
13
+
14
+    &.QrCodeImg {
15
+      position: absolute;
16
+      z-index: 2;
17
+      width: 50%;
18
+      height: auto;
19
+    }
13 20
   }
14 21
 }

+ 10
- 9
src/utils/qrcode.js 查看文件

@@ -1,15 +1,16 @@
1 1
 import { apis, request2 } from './request'
2 2
 
3
-export function getCardQrParam(user) {
4
-  const param = [
5
-    `id=${user.personId}`,
6
-    `from=card`,
7
-    `recommender=${user.personId}`
8
-  ]
3
+export function getCardQrParam (user) {
4
+  // const param = [
5
+  //   `id=${user.personId}`,
6
+  //   `from=card`,
7
+  //   `recommender=${user.personId}`
8
+  // ]
9 9
 
10
-  return param.join('&')
10
+  // return param.join('&')
11
+  return {id: user.personId, from: 'card', recommender: user.personId}
11 12
 }
12 13
 
13
-export function getQrCodeImage(data) {
14
-  return request2({...apis.qrcode, data})
14
+export function getQrCodeImage (data) {
15
+  return request2({ ...apis.qrcode, data: { ...data } })
15 16
 }