支付宝小程序 头部导航背景颜色渐变
页面的json中写入
export default {
navigationBarTitleText: "",
enablePullDownRefresh: true,
transparentTitle: "always",
titlePenetrate: "YES"
};
view
<view class="cdn"> </view>
css
.cdn {
position: fixed;
width: 100%;
height: 269px;
// background-image: url("../../static/img/bg2x.png");
// background-size: cover;
background-image: linear-gradient(
269deg,
rgba(0, 170, 177, 0.99) 0%,
#02c5cc 100%
);
background-image: linear-gradient(269deg, #009ee7 1%, #13b4ff 100%);
background-image: linear-gradient(269deg, #0094d9 1%, #13b4ff 100%);
background-image: linear-gradient(128deg, #e3f7ff 15%, #3f9fff 100%);
}
下面是ocr图片识别
chooseImage() {
const that = this;
Taro.chooseImage({
sizeType: [“original”, “compressed”], // 可以指定是原图还是压缩图,默认二者都有
sourceType: [“album”, “camera”], // 可以指定来源是相册还是相机,默认二者都有
success(res) {
console.log(res);
let file = res.tempFilePaths[0];
that.files = res.tempFilePaths[0];
console.log(file);
Taro.getImageInfo({
src: file,
success(imageInfo) {
var imgType = imageInfo.type;
console.log(imageInfo);
Taro.getFileSystemManager().readFile({
filePath: file, //选择图片返回的相对路径
encoding: “base64”, //这个是很重要的
success: (res) => {
//成功的回调
//返回base64格式
var base64Str =
“data:image/” + imgType + “;base64,” + res.data;
// console.log(base64Str);
var img = res.data;
console.log(img);
// that.uploadImg(base64Str);
that.uploadImg(img);
},
fail: (err) => {
console.log(err);
reject(err);
},
});
},
});
},
});
},
uploadImg(img) {
OCR01({
img_content: img,
}).then((res) => {
console.log(res);
this.name = res.name;
this.num = res.num;
setSessionStore(“name”, res.name);
setSessionStore(“num”, res.num);
});
},
chooseImage() {
const that = this;
Taro.chooseImage({
sizeType: [“original”, “compressed”], // 可以指定是原图还是压缩图,默认二者都有
sourceType: [“album”, “camera”], // 可以指定来源是相册还是相机,默认二者都有
success(res) {
console.log(res);
let file = res.tempFilePaths[0];
that.files = res.tempFilePaths[0];
console.log(file);
Taro.getImageInfo({
src: file,
success(imageInfo) {
var imgType = imageInfo.type;
console.log(imageInfo);
Taro.getFileSystemManager().readFile({
filePath: file, //选择图片返回的相对路径
encoding: “base64”, //这个是很重要的
success: (res) => {
//成功的回调
//返回base64格式
var base64Str =
“data:image/” + imgType + “;base64,” + res.data;
// console.log(base64Str);
var img = res.data;
console.log(img);
// that.uploadImg(base64Str);
that.uploadImg(img);
},
fail: (err) => {
console.log(err);
reject(err);
},
});
},
});
},
});
},
uploadImg(img) {
OCR01({
img_content: img,
}).then((res) => {
console.log(res);
this.name = res.name;
this.num = res.num;
setSessionStore(“name”, res.name);
setSessionStore(“num”, res.num);
});
},