Commit a8434f56 by luyt

feat:调整标题

1 parent 660fe85c
...@@ -66,9 +66,11 @@ Page({ ...@@ -66,9 +66,11 @@ Page({
let item = senceData[actNum]?.productList[activeNavIdx] let item = senceData[actNum]?.productList[activeNavIdx]
console.log('title',item.productName) console.log('title',item.productName)
setTimeout(() => { setTimeout(() => {
wx.setNavigationBarTitle({ // wx.setNavigationBarTitle({
title: item.productName, // title: " "+item.productName,
}); // });
utils.setNavigationBarTitle(item.productName)
},100) },100)
this.shareQuery = `sceneCode=${senceItem?.sceneCode}&productCode=${item?.productCode}&isShare=${true}&productDesc=${item?.productName}&category=${item?.category}&actNum=${actNum}&activeNavIdx=${activeNavIdx}&phone=${phone}` this.shareQuery = `sceneCode=${senceItem?.sceneCode}&productCode=${item?.productCode}&isShare=${true}&productDesc=${item?.productName}&category=${item?.category}&actNum=${actNum}&activeNavIdx=${activeNavIdx}&phone=${phone}`
...@@ -106,9 +108,11 @@ Page({ ...@@ -106,9 +108,11 @@ Page({
let item = senceData[actNum]?.productList[activeNavIdx] let item = senceData[actNum]?.productList[activeNavIdx]
console.log('title2',item.productName) console.log('title2',item.productName)
setTimeout(() => { setTimeout(() => {
wx.setNavigationBarTitle({ // wx.setNavigationBarTitle({
title: item.productName, // title: " "+item.productName,
}); // });
utils.setNavigationBarTitle(item.productName)
},100) },100)
......
...@@ -4,6 +4,5 @@ ...@@ -4,6 +4,5 @@
"apply-button":"../viewVideo/components/apply-button/index", "apply-button":"../viewVideo/components/apply-button/index",
"van-tab": "@vant/weapp/tab/index", "van-tab": "@vant/weapp/tab/index",
"van-tabs": "@vant/weapp/tabs/index" "van-tabs": "@vant/weapp/tabs/index"
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -62,9 +62,10 @@ Page({ ...@@ -62,9 +62,10 @@ Page({
let item = senceData[actNum]?.productList[activeNavIdx] let item = senceData[actNum]?.productList[activeNavIdx]
console.log('title',item.productName) console.log('title',item.productName)
setTimeout(() => { setTimeout(() => {
wx.setNavigationBarTitle({ // wx.setNavigationBarTitle({
title: item.productName, // title: item.productName,
}); // });
utils.setNavigationBarTitle(item.productName)
},100) },100)
this.shareQuery = `sceneCode=${senceItem?.sceneCode}&productCode=${item?.productCode}&isShare=${true}&productDesc=${item?.productName}&category=${item?.category}&actNum=${actNum}&activeNavIdx=${activeNavIdx}&phone=${phone}` this.shareQuery = `sceneCode=${senceItem?.sceneCode}&productCode=${item?.productCode}&isShare=${true}&productDesc=${item?.productName}&category=${item?.category}&actNum=${actNum}&activeNavIdx=${activeNavIdx}&phone=${phone}`
...@@ -102,9 +103,10 @@ Page({ ...@@ -102,9 +103,10 @@ Page({
let item = senceData[actNum]?.productList[activeNavIdx] let item = senceData[actNum]?.productList[activeNavIdx]
console.log('title2',item.productName) console.log('title2',item.productName)
setTimeout(() => { setTimeout(() => {
wx.setNavigationBarTitle({ // wx.setNavigationBarTitle({
title: item.productName, // title: item.productName,
}); // });
utils.setNavigationBarTitle(item.productName)
},100) },100)
......
...@@ -93,9 +93,10 @@ Page({ ...@@ -93,9 +93,10 @@ Page({
setpagesTitle(){ setpagesTitle(){
//设置标题 //设置标题
let {videoitem} = this.data let {videoitem} = this.data
wx.setNavigationBarTitle({ // wx.setNavigationBarTitle({
title: videoitem.name, // title: videoitem.name,
}); // });
utils.setNavigationBarTitle(videoitem.name)
}, },
// 视频下载 // 视频下载
downVideo() { downVideo() {
......
...@@ -160,6 +160,7 @@ const getCurrentPageUrl = () =>{ ...@@ -160,6 +160,7 @@ const getCurrentPageUrl = () =>{
return url return url
} }
// 克隆
const deepClone = (target) => { const deepClone = (target) => {
const map = new WeakMap() const map = new WeakMap()
...@@ -223,6 +224,39 @@ const deepClone = (target) => { ...@@ -223,6 +224,39 @@ const deepClone = (target) => {
return clone(target) return clone(target)
} }
//设置标题
const setNavigationBarTitle = (title) =>{
wx.getSystemInfo({
success: (res) => {
// console.log('++++++++++++++', res);
// console.log('title length',title.length)
let width = res.safeArea.width / res.fontSizeSetting;
// console.log('width: ', width);
let space = '';
// for (let i = 0; i <= width+4; i++) {
// space = space + ' ';
// }
width = width-(title.length)/2
for (let i = 0; i < width; i++) {
space = space + ' ';
}
if (res.system.includes('iOS') === false) {
wx.setNavigationBarTitle({
title: space + title
});
} else {
wx.setNavigationBarTitle({
title: title
});
}
}
});
}
const Util = { const Util = {
getImgVersion, getImgVersion,
onReachBottom, onReachBottom,
...@@ -232,6 +266,7 @@ const Util = { ...@@ -232,6 +266,7 @@ const Util = {
isEmptyObj, isEmptyObj,
parseString, parseString,
getCurrentPageUrl, getCurrentPageUrl,
deepClone deepClone,
setNavigationBarTitle
}; };
export default Util; export default Util;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!