From d2212709606b4e2af14d6a874f5f827767d7411c Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期一, 29 七月 2024 13:46:27 +0800
Subject: [PATCH] ''
---
wechat_jiaxuan/pages/detailDis/product.js | 18 +--
wechat_staff/pages/detailDis/case.wxml | 44 +++++-----
wechat_jiaxuan/pages/detailDis/realpic.js | 19 +---
wechat_jiaxuan/utils/login-sdk.js | 67 ++++++++++++++++
wechat_staff/static/icon/ic_select_sel@2x.png | 0
wechat_staff/pages/detailDis/realpic.wxml | 15 ++-
wechat_jiaxuan/app.js | 42 +++++++---
wechat_staff/components/detailFooter/index.less | 4
wechat_staff/components/detailFooter/index.wxss | 4
wechat_jiaxuan/package.json | 1
wechat_jiaxuan/pages/detailDis/case.js | 16 +--
wechat_staff/pages/detailDis/product.js | 1
wechat_jiaxuan/pages/index/index.js | 9 +
13 files changed, 159 insertions(+), 81 deletions(-)
diff --git a/wechat_jiaxuan/app.js b/wechat_jiaxuan/app.js
index 1cc3c46..4bb2f46 100644
--- a/wechat_jiaxuan/app.js
+++ b/wechat_jiaxuan/app.js
@@ -1,11 +1,14 @@
import {
wxLoginCustomer
} from './api/index'
+import CustomHook from 'spa-custom-hooks';
+let globalData = {
+ token: '',
+ primary: '#B08771',
+ bottomLift: ''
+}
App({
- globalData: {
- primary: '#B08771',
- bottomLift: ''
- },
+ globalData,
onLaunch: function (op) {
console.log('options', op.query.scene)
let pathMap = [
@@ -23,24 +26,25 @@
// 鎺堟潈鐧诲綍
wx.login({
timeout: 5000,
- success(res) {
+ success: (res) => {
if (res.code) {
//鍙戣捣缃戠粶璇锋眰
wxLoginCustomer({
code: res.code
}).then(res => {
- console.log(res)
+ wx.setStorageSync('token', res.data.token)
+ this.globalData.token = res.data.token
+ if (op.query.scene) {
+ let temp = op.query.scene.split('_')
+ wx.navigateTo({
+ url: `${pathMap[temp[1]]}?id=${temp[0]}&userId=${temp[2]}`,
+ })
+ }
+ console.log('鎷垮埌token浜�', res.data.token);
if (res && res.data.member) {
wx.setStorageSync('member', res.data.member)
wx.setStorageSync('openid', res.data.member.openid)
wx.setStorageSync('sessionKey', res.data.sessionKey)
- wx.setStorageSync('token', res.data.token)
- if (op.query.scene) {
- let temp = op.query.scene.split('_')
- wx.navigateTo({
- url: `${pathMap[temp[1]]}?id=${temp[0]}&userId=${temp[2]}`,
- })
- }
} else {
console.log('鐧诲綍澶辫触锛�')
}
@@ -57,4 +61,14 @@
}
-})
\ No newline at end of file
+})
+CustomHook.install({
+ 'Login':{
+ name:'Login',
+ watchKey: 'token',
+ onUpdate(val){
+ //鏈塼oken鍒欒Е鍙戞閽╁瓙
+ return !!val;
+ }
+ }
+ }, globalData || 'globalData')
\ No newline at end of file
diff --git a/wechat_jiaxuan/package.json b/wechat_jiaxuan/package.json
index 4c96408..78d8b88 100644
--- a/wechat_jiaxuan/package.json
+++ b/wechat_jiaxuan/package.json
@@ -7,6 +7,7 @@
"@vant/weapp": "^1.11.6",
"hy-event-store": "^1.3.1",
"mp-html": "^2.5.0",
+ "spa-custom-hooks": "^1.2.2",
"vant-weapp": "^0.5.28"
},
"scripts": {
diff --git a/wechat_jiaxuan/pages/detailDis/case.js b/wechat_jiaxuan/pages/detailDis/case.js
index a5b7207..4e5301a 100644
--- a/wechat_jiaxuan/pages/detailDis/case.js
+++ b/wechat_jiaxuan/pages/detailDis/case.js
@@ -9,10 +9,13 @@
origin: '',
showShare: false
},
-
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
- */
+ onLoadLogin(options){
+ this.getDetail(options.id, options.userId || '')
+ actionDo({
+ actionType: 'view',
+ id: options.id
+ })
+ },
onLoad(options) {
var app = getApp().globalData
this.setData({
@@ -21,11 +24,6 @@
if(options.origin && options.origin == 'b'){
this.setData({ origin: 'b' })
}
- this.getDetail(options.id, options.userId || '')
- actionDo({
- actionType: 'view',
- id: options.id
- })
const member = wx.getStorageSync('member')
this.setData({id: options.id, member})
},
diff --git a/wechat_jiaxuan/pages/detailDis/product.js b/wechat_jiaxuan/pages/detailDis/product.js
index 17fdea7..fd243ff 100644
--- a/wechat_jiaxuan/pages/detailDis/product.js
+++ b/wechat_jiaxuan/pages/detailDis/product.js
@@ -1,10 +1,8 @@
import {
- shareContent,
getProductInfo,
actionDo
} from '../../api/index'
Page({
-
/**
* 椤甸潰鐨勫垵濮嬫暟鎹�
*/
@@ -17,9 +15,13 @@
member: {},
showShare: false
},
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
- */
+ onLoadLogin(options){
+ this.getDetail(options.id, options.userId || '')
+ actionDo({
+ actionType: 'view',
+ id: options.id
+ })
+ },
onLoad(options) {
var app = getApp().globalData
this.setData({
@@ -28,11 +30,6 @@
if(options.origin && options.origin == 'b'){
this.setData({ origin: 'b' })
}
- this.getDetail(options.id, options.userId || '')
- actionDo({
- actionType: 'view',
- id: options.id
- })
const member = wx.getStorageSync('member')
this.setData({
id: options.id,
@@ -40,7 +37,6 @@
})
},
bindchange(e) {
- console.log('e', e.detail );
this.setData({ current: e.detail.current })
},
priviewBanner(e) {
diff --git a/wechat_jiaxuan/pages/detailDis/realpic.js b/wechat_jiaxuan/pages/detailDis/realpic.js
index aa0d883..94714ac 100644
--- a/wechat_jiaxuan/pages/detailDis/realpic.js
+++ b/wechat_jiaxuan/pages/detailDis/realpic.js
@@ -1,9 +1,5 @@
import { getRealcaseInfo, actionDo } from '../../api/index'
Page({
-
- /**
- * 椤甸潰鐨勫垵濮嬫暟鎹�
- */
data: {
bottomLift: 0,
id: '',
@@ -13,9 +9,13 @@
showShare: false
},
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
- */
+ onLoadLogin(options){
+ this.getDetail(options.id, options.userId || '')
+ actionDo({
+ actionType: 'view',
+ id: options.id
+ })
+ },
onLoad(options) {
var app = getApp().globalData
this.setData({
@@ -24,11 +24,6 @@
if(options.origin && options.origin == 'b'){
this.setData({ origin: 'b' })
}
- this.getDetail(options.id, options.userId || '')
- actionDo({
- actionType: 'view',
- id: options.id
- })
const member = wx.getStorageSync('member')
this.setData({id: options.id, member})
},
diff --git a/wechat_jiaxuan/pages/index/index.js b/wechat_jiaxuan/pages/index/index.js
index 2e777c9..e66444b 100644
--- a/wechat_jiaxuan/pages/index/index.js
+++ b/wechat_jiaxuan/pages/index/index.js
@@ -12,6 +12,7 @@
HYEventBus
} = require('hy-event-store')
const eventBus = new HYEventBus()
+const app = getApp()
Page({
/**
@@ -48,6 +49,11 @@
HOME_CLASS_B2: '',
HOME_CLASS_C: '',
},
+ onLoadLogin(options){
+ // 宸茬粡鐧诲綍锛屽彲浠ヨ蛋渚濊禆token鐨勯�昏緫浜�
+ console.log('棣栭〉鐨刼nLoadLogin',options,`{"token":"${app.globalData.token}"}`);
+ this.initData()
+ },
onShow() {
let that = this
const member = wx.getStorageSync('member')
@@ -70,9 +76,6 @@
onLoad(options) {
const member = wx.getStorageSync('member')
this.initDictData()
- setTimeout(() => {
- this.initData()
- }, 1200)
},
changePath(e) {
let index = e.currentTarget.dataset.type
diff --git a/wechat_jiaxuan/utils/login-sdk.js b/wechat_jiaxuan/utils/login-sdk.js
new file mode 100644
index 0000000..8293c47
--- /dev/null
+++ b/wechat_jiaxuan/utils/login-sdk.js
@@ -0,0 +1,67 @@
+let isLogin = false;
+
+// 鍙戝竷璁㈤槄妯″紡
+class Publisher {
+ constructor() {
+ this.map = new Map();
+ }
+ on(key, callback) {
+ let arr = this.map.get(key) || [];
+ arr.push(callback);
+ this.map.set(key, arr);
+ }
+ emit(key, data = {}) {
+ if (this.map.has(key)) {
+ this.map.get(key).forEach((item) => {
+ item.call(this, data);
+ });
+ }
+ }
+}
+
+let publisher = new Publisher();
+
+// 椤甸潰鎵╁睍
+const oldPage = Page;
+Page = function (pageParams) {
+ const { onLoad, onShow, onReady } = pageParams;
+
+ pageParams.onLoad = function (params) {
+ // 鍒ゆ柇鏄惁鐧婚檰
+ if (isLogin) {
+ onLoad && onLoad.call(this, params);
+ } else {
+ publisher.on("login", () => {
+ isLogin = true;
+ onLoad && onLoad.call(this, params);
+ });
+ }
+ };
+
+ pageParams.onShow = function () {
+ // 鍒ゆ柇鏄惁鐧婚檰
+ if (isLogin) {
+ onShow && onShow.call(this);
+ } else {
+ publisher.on("login", () => {
+ onShow && onShow.call(this);
+ });
+ }
+ };
+
+ pageParams.onReady = function () {
+ // 鍒ゆ柇鏄惁鐧婚檰
+ if (isLogin) {
+ onReady && onReady.call(this);
+ } else {
+ publisher.on("login", () => {
+ onReady && onReady.call(this);
+ });
+ }
+ };
+ return oldPage(pageParams);
+};
+
+module.exports = {
+ publisher,
+};
diff --git a/wechat_staff/components/detailFooter/index.less b/wechat_staff/components/detailFooter/index.less
index c2d4477..a058cab 100644
--- a/wechat_staff/components/detailFooter/index.less
+++ b/wechat_staff/components/detailFooter/index.less
@@ -67,7 +67,7 @@
height: 264rpx;
display: flex;
align-items: center;
- padding: 0 40rpx;
+ padding: 0 60rpx;
.item{
display: flex;
flex-direction: column;
@@ -89,7 +89,7 @@
display: flex;
justify-content: center;
align-items: center;
- border: 1rpx solid #e5e5e5;
+ border-top: 1rpx solid #e5e5e5;
}
}
.shade{
diff --git a/wechat_staff/components/detailFooter/index.wxss b/wechat_staff/components/detailFooter/index.wxss
index e77b917..d156385 100644
--- a/wechat_staff/components/detailFooter/index.wxss
+++ b/wechat_staff/components/detailFooter/index.wxss
@@ -64,7 +64,7 @@
height: 264rpx;
display: flex;
align-items: center;
- padding: 0 40rpx;
+ padding: 0 60rpx;
}
.shade_modal .btns .item {
display: flex;
@@ -86,7 +86,7 @@
display: flex;
justify-content: center;
align-items: center;
- border: 1rpx solid #e5e5e5;
+ border-top: 1rpx solid #e5e5e5;
}
.shade {
position: fixed;
diff --git a/wechat_staff/pages/detailDis/case.wxml b/wechat_staff/pages/detailDis/case.wxml
index 2929e65..499243d 100644
--- a/wechat_staff/pages/detailDis/case.wxml
+++ b/wechat_staff/pages/detailDis/case.wxml
@@ -1,26 +1,28 @@
-<view class="container">
- <buoyClient showPurpose="1" class="buoyClient"/>
+<view>
+ <buoyClient showPurpose="1" class="buoyClient" />
<detailFooter bindenjoy="handleEnjoy" path="1" info="{{info}}" />
- <view class="main_title">{{ info.title }}</view>
- <view class="time">鍙戝竷鏃堕棿锛歿{ info.publishDt }}</view>
- <view class="fullview_wrap">
- <view bindtap="priviewFull" wx:if="{{ info.panorama }}" class="full">
- <image class="icon" src="../../static/icon/ic_720.png" mode="widthFix"></image>
- <text>鍏ㄦ櫙</text>
+ <view class="container">
+ <view class="main_title">{{ info.title }}</view>
+ <view class="time">鍙戝竷鏃堕棿锛歿{ info.publishDt }}</view>
+ <view class="fullview_wrap">
+ <view bindtap="priviewFull" wx:if="{{ info.panorama }}" class="full">
+ <image class="icon" src="../../static/icon/ic_720.png" mode="widthFix"></image>
+ <text>鍏ㄦ櫙</text>
+ </view>
+ <image class="banner" src="{{ info.coverImage }}" mode="widthFix"></image>
</view>
- <image class="banner" src="{{ info.coverImage }}" mode="widthFix"></image>
- </view>
- <view class="h1">甯冪疆鍥�</view>
- <image bindtap="priviewLayout" class="img" src="{{ info.layoutUlr }}" mode="widthFix"></image>
- <view class="analysis">
- <view class="h2">妗堜緥瑙f瀽</view>
- <view class="text">{{ info.caseInfo }}</view>
- </view>
- <view class="list">
- <view wx:for="{{ info.apiSpaceCaseVos }}" class="item">
- <view class="h1">{{ item.spaceName }}</view>
- <image data-url="{{ img }}" bindtap="priviewSpace" class="img" wx:for="{{ item.imgList }}" wx:for-item="img" src="{{ img }}" mode="widthFix" />
- <view class="content">{{ item.spaceDesc }}</view>
+ <view class="h1">甯冪疆鍥�</view>
+ <image bindtap="priviewLayout" class="img" src="{{ info.layoutUlr }}" mode="widthFix"></image>
+ <view class="analysis">
+ <view class="h2">妗堜緥瑙f瀽</view>
+ <view class="text">{{ info.caseInfo }}</view>
+ </view>
+ <view class="list">
+ <view wx:for="{{ info.apiSpaceCaseVos }}" class="item">
+ <view class="h1">{{ item.spaceName }}</view>
+ <image data-url="{{ img }}" bindtap="priviewSpace" class="img" wx:for="{{ item.imgList }}" wx:for-item="img" src="{{ img }}" mode="widthFix" />
+ <view class="content">{{ item.spaceDesc }}</view>
+ </view>
</view>
</view>
<!-- footer -->
diff --git a/wechat_staff/pages/detailDis/product.js b/wechat_staff/pages/detailDis/product.js
index 2169600..f22f525 100644
--- a/wechat_staff/pages/detailDis/product.js
+++ b/wechat_staff/pages/detailDis/product.js
@@ -97,7 +97,6 @@
})
},
bindchange(e) {
- console.log('e', e.detail );
this.setData({ current: e.detail.current })
},
priviewSpace(e) {
diff --git a/wechat_staff/pages/detailDis/realpic.wxml b/wechat_staff/pages/detailDis/realpic.wxml
index 9534c5d..21ebea9 100644
--- a/wechat_staff/pages/detailDis/realpic.wxml
+++ b/wechat_staff/pages/detailDis/realpic.wxml
@@ -1,11 +1,14 @@
-<view class="container">
- <buoyClient showPurpose="1" class="buoyClient"/>
+<view>
+ <buoyClient showPurpose="1" class="buoyClient" />
<detailFooter bindenjoy="handleEnjoy" path="2" info="{{info}}" />
<!-- -->
- <view class="main_title">{{ info.title }}</view>
- <view class="time">鍙戝竷鏃堕棿锛歿{ info.publishDt }}</view>
- <image data-url="{{ item }}" bindtap="priviewSpace" class="info_item" wx:for="{{ info.contentImgList }}" src="{{ item }}" mode="widthFix"></image>
- <view class="desc">{{ info.contentText || '' }}</view>
+ <view class="container">
+ <view class="main_title">{{ info.title }}</view>
+ <view class="time">鍙戝竷鏃堕棿锛歿{ info.publishDt }}</view>
+ <image data-url="{{ item }}" bindtap="priviewSpace" class="info_item" wx:for="{{ info.contentImgList }}" src="{{ item }}" mode="widthFix"></image>
+ <view class="desc">{{ info.contentText || '' }}</view>
+ </view>
+
<!-- <view class="list">
<view class="item">
<image src="" mode="widthFix" />
diff --git a/wechat_staff/static/icon/ic_select_sel 2.png b/wechat_staff/static/icon/ic_select_sel@2x.png
similarity index 100%
rename from wechat_staff/static/icon/ic_select_sel 2.png
rename to wechat_staff/static/icon/ic_select_sel@2x.png
Binary files differ
--
Gitblit v1.9.3