Skip to content
This repository was archived by the owner on Sep 21, 2023. It is now read-only.

Commit

Permalink
add jImage component for 403 images
Browse files Browse the repository at this point in the history
  • Loading branch information
myvin committed Oct 15, 2019
1 parent 574f612 commit b4b497d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ App({
},
globalData: {
systeminfo: {},
imageServer: 'https://images.weserv.nl/',
config: {
loginRequestUrlByMobile: 'https://juejin.im/auth/type/phoneNumber',
loginRequestUrlByEMail: 'https://juejin.im/auth/type/email',
Expand Down
22 changes: 22 additions & 0 deletions components/jImage/jImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Component({
properties: {
src: {
type: String,
value: '',
observer: function (newVal) {
this.setSrc(newVal)
}
},
},
attached: function () {
this.setSrc(this.data.src)
},
methods: {
setSrc (src) {
const imgSrc = `${getApp().globalData.imageServer}?url=${src}`
this.setData({
imgSrc,
})
}
},
})
3 changes: 3 additions & 0 deletions components/jImage/jImage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"component": true
}
1 change: 1 addition & 0 deletions components/jImage/jImage.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<image mode='aspectFill' class="img" src="{{imgSrc}}"></image>
4 changes: 4 additions & 0 deletions components/jImage/jImage.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image.img {
width: 100%;
height: 100%;
}

0 comments on commit b4b497d

Please sign in to comment.