Commit 3a595e4c by 高淑倩

formateUrl

parent 22c344e2
...@@ -14,8 +14,10 @@ Component({ ...@@ -14,8 +14,10 @@ Component({
value: null value: null
} }
}, },
attached () { attached() {
this.setData({
baseImgUrl: app.globalData.imageUrl
})
}, },
/** /**
* 组件的初始数据 * 组件的初始数据
......
<!--component/announcement/announcement.wxml--> <!--component/announcement/announcement.wxml-->
<wxs src="../../wxs/utils.wxs" module="utils" />
<view class="announcement df" style="background-color:{{notice.backgroundColor}}" data-redirectId="{{notice.redirectId}}" bindtap="handelToAnn"> <view class="announcement df" style="background-color:{{notice.backgroundColor}}" data-redirectId="{{notice.redirectId}}" bindtap="handelToAnn">
<view class="horn"> <view class="horn">
<image class="img" src="{{notice.iconImageUrl? 'notice.iconImageUrl': '/assets/imgs/7_1_0/notice.png'}}" mode="widthFix" lazy-load="false" binderror="" bindload="" /> <image class="img" src="{{notice.iconImageUrl? utils.formateUrl(notice.iconImageUrl,baseImgUrl) : '/assets/imgs/7_1_0/notice.png'}}" mode="widthFix" />
<!--<image class="img" src="{{notice.iconImageUrl? 'notice.iconImageUrl': '/assets/imgs/7_1_0/notice.png'}}" mode="widthFix" />-->
</view> </view>
<text class="text" style="color:{{notice.fontColor}}">{{notice.content}}</text> <text class="text" style="color:{{notice.fontColor}}">{{notice.content}}</text>
</view> </view>
\ No newline at end of file
<!--component/imageSwiper/imageSwiper.wxml--> <!--component/imageSwiper/imageSwiper.wxml-->
<wxs src="../../wxs/utils.wxs" module="utils" />
<swiper <swiper
class="image-swiper" class="image-swiper"
indicator-dots="{{indicatorDots}}" indicator-dots="{{indicatorDots}}"
...@@ -18,7 +19,7 @@ ...@@ -18,7 +19,7 @@
data-item="{{item}}" data-item="{{item}}"
bindtap='preview' bindtap='preview'
> >
<image bindload="imageLoad" src="{{item.imageUrl}}" id="swiperImg{{index}}" mode="widthFix" class="slide-image" /> <image bindload="imageLoad" src="{{utils.formateUrl(item.imageUrl,baseImgUrl)}}" id="swiperImg{{index}}" mode="widthFix" class="slide-image" />
</view> </view>
</swiper-item> </swiper-item>
</block> </block>
......
<!--component/personCenter/personCenter.wxml--> <!--component/personCenter/personCenter.wxml-->
<wxs src="../../wxs/utils.wxs" module="utils" />
<view wx:if='{{!currentMobile}}' class="member-unActive {{personCenter.noactiveBackgroundImageUrl ?'':'member-unActive-bgc'}}" bindtap="handleTtoActiveMemebr"> <view wx:if='{{!currentMobile}}' class="member-unActive {{personCenter.noactiveBackgroundImageUrl ?'':'member-unActive-bgc'}}" bindtap="handleTtoActiveMemebr">
<image wx:if="{{baseImgUrl}}" src="{{baseImgUrl}}{{personCenter.noactiveBackgroundImageUrl}}" class="no-active-img" mode="widthFix"></image> <image src="{{utils.formateUrl(personCenter.noactiveBackgroundImageUrl,baseImgUrl)}}" class="no-active-img" mode="widthFix"></image>
</view> </view>
<view wx:if='{{currentMobile}}' catchtap="handleToMemberOfOwn" class="activation-content activation-bg {{true ? 'user-content' : ''}}" style="{{personData.backgroundImageUrl ? 'background-image: url('+ baseImgUrl +''+ personData.backgroundImageUrl +');' : 'background-color: ' + baseUrl + ';'}}"> <view wx:if='{{currentMobile}}' catchtap="handleToMemberOfOwn" class="activation-content activation-bg {{true ? 'user-content' : ''}}" style="{{personData.backgroundImageUrl ? 'background-image: url('+ baseImgUrl +''+ personData.backgroundImageUrl +');' : 'background-color: ' + baseUrl + ';'}}">
<view class='user-info' wx:if='{{currentMobile}}'> <view class='user-info' wx:if='{{currentMobile}}'>
......
<!--component/picNav/picNav.wxml--> <!--component/picNav/picNav.wxml-->
<wxs src="../../wxs/utils.wxs" module="utils" />
<view class="pic-nav"> <view class="pic-nav">
<view <view
wx:for="{{picNav}}" wx:for="{{picNav}}"
...@@ -10,7 +11,7 @@ ...@@ -10,7 +11,7 @@
wx:if="{{baseImgUrl}}" wx:if="{{baseImgUrl}}"
class="pic-img" class="pic-img"
style="width: {{100}}%;height: {{100}}px;" style="width: {{100}}%;height: {{100}}px;"
src="{{item.imageUrl}}" src="{{utils.formateUrl(item.imageUrl,baseImgUrl)}}"
data-appid="{{item.link.appid}}" data-appid="{{item.link.appid}}"
data-path="{{item.link.url}}" data-path="{{item.link.url}}"
data-link="{{item.link}}" data-link="{{item.link}}"
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
"list": [] "list": []
}, },
"miniprogram": { "miniprogram": {
"current": 40, "current": 13,
"list": [ "list": [
{ {
"id": -1, "id": -1,
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
"id": 13, "id": 13,
"name": "subPage", "name": "subPage",
"pathName": "subPackage/page/pages/subPage/subPage", "pathName": "subPackage/page/pages/subPage/subPage",
"query": "pageId=14", "query": "pageId=16",
"scene": null "scene": null
}, },
{ {
......
...@@ -20,8 +20,16 @@ function handerNickName (nickName,limitLength) { ...@@ -20,8 +20,16 @@ function handerNickName (nickName,limitLength) {
return nickName || '' return nickName || ''
} }
// 处理 http 地址
function formateUrl(url, BASE_IMG_URL){
if(url){
url = url.indexOf('http') > -1 ? url : BASE_IMG_URL + url;
}
return url;
}
module.exports = { module.exports = {
formateUrl:formateUrl,
numberFormat: numberFormat, numberFormat: numberFormat,
date: date, date: date,
handerNickName: handerNickName handerNickName: handerNickName
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment