微信小程序适配

feasure
lld 2026-02-15 12:58:43 +08:00
parent 982a5738df
commit a174606e2b
7 changed files with 236 additions and 12 deletions

View File

@ -1,7 +1,7 @@
// 应用全局配置 // 应用全局配置
module.exports = { module.exports = {
// baseUrl: process.env.UNI_PLATFORM === 'mp-weixin'?"http://122.51.109.52:8088":(process.env.NODE_ENV === "production" ? "/api" : "http://localhost:8088"), // baseUrl: process.env.UNI_PLATFORM === 'mp-weixin'?"http://122.51.109.52:8088":(process.env.NODE_ENV === "production" ? "/api" : "http://localhost:8088"),
baseUrl: process.env.NODE_ENV === "production"?"https://api.xiaoces.com/api":"http://localhost:8088", baseUrl: process.env.NODE_ENV === "production"?"https://api.xiaoces.com/api":"http://172.14.24.107:8088",
// 应用信息 // 应用信息
appInfo: { appInfo: {
// 应用名称 // 应用名称

View File

@ -3,11 +3,20 @@
<uni-popup ref="addForm" mode="center" > <uni-popup ref="addForm" mode="center" >
<!-- 新增修改运行时间的弹窗 --> <!-- 新增修改运行时间的弹窗 -->
<view class="modal-container"> <view class="modal-container">
<view class="modal-title">{{ `【- 实时温湿度】别名设置` }}</view> <view class="modal-title">{{ `添加大棚` }}</view>
<view class="modal-input-wrap" > <view class="modal-input-wrap" >
<text class="modal-label">别名设置</text> <text class="modal-label">大棚名称</text>
<uni-easyinput style="width: 100px" v-model="remark" placeholder="不填展示默认备注" /> <uni-easyinput style="width: 100px" v-model="agriName" placeholder="请输入大棚名称" />
</view> </view>
<view class="modal-input-wrap" >
<text class="modal-label">设备imei</text>
<uni-easyinput style="width: 100px" v-model="imei" placeholder="请输入大棚名称" >
<template #right>
<yt-scanCode @getScanCode="getScanCode"></yt-scanCode>
</template>
</uni-easyinput>
</view>
<view class="modal-btn-wrap"> <view class="modal-btn-wrap">
<button class="modal-btn cancel" @click="close"></button> <button class="modal-btn cancel" @click="close"></button>
<button class="modal-btn confirm" @click="confirm"></button> <button class="modal-btn confirm" @click="confirm"></button>
@ -15,6 +24,9 @@
</view> </view>
</uni-popup> </uni-popup>
</view> </view>
</template> </template>
<script> <script>
@ -25,7 +37,8 @@ export default {
components: {UniPopup}, components: {UniPopup},
data() { data() {
return { return {
remark: 'qeqweqeqw' agriName: null,
imei:null
} }
}, },
methods:{ methods:{
@ -38,7 +51,10 @@ export default {
open() { open() {
this.$refs.addForm.open(); this.$refs.addForm.open();
}, },
getScanCode(res){
console.log("设备号======>",res);
}
} }
} }
</script> </script>
@ -62,11 +78,11 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 35rpx; margin-bottom: 35rpx;
font-size: 26rpx; font-size: 28rpx;
margin-left: 20rpx; margin-left: 20rpx;
} }
.modal-label { .modal-label {
width: 160rpx; width: 140rpx;
color: #666; color: #666;
} }
.modal-current { .modal-current {
@ -78,7 +94,7 @@ export default {
border: 1px solid #eee; border: 1px solid #eee;
border-radius: 8rpx; border-radius: 8rpx;
padding: 0 15rpx; padding: 0 15rpx;
font-size: 26rpx; font-size: 28rpx;
width: 80rpx; width: 80rpx;
} }
.modal-unit { .modal-unit {
@ -94,7 +110,7 @@ export default {
flex: 1; flex: 1;
height: 70rpx; height: 70rpx;
border-radius: 8rpx; border-radius: 8rpx;
font-size: 26rpx; font-size: 28rpx;
} }
.modal-btn.cancel { .modal-btn.cancel {
background: #f5f5f5; background: #f5f5f5;

View File

@ -390,7 +390,7 @@ page {
.item-tags { .item-tags {
display: flex; display: flex;
gap: 12rpx; gap: 10rpx;
flex-wrap: wrap; /* 新增:标签过多时换行,避免溢出 */ flex-wrap: wrap; /* 新增:标签过多时换行,避免溢出 */
margin: 14rpx 0; margin: 14rpx 0;
} }
@ -496,10 +496,18 @@ page {
} }
/deep/ .uni-select { /deep/ .uni-select {
border: 0; border: 0;
height: 78rpx; // #ifndef MP-WEIXIN
height: 70rpx !important;
// #endif
// #ifdef MP-WEIXIN
margin-top: 20rpx !important;
height: 66rpx !important;
// #endif
border-radius: 10rpx 0 0 10rpx !important; border-radius: 10rpx 0 0 10rpx !important;
} }
/deep/ .uni-section {
background: transparent !important;
}
/* 强制隐藏搜索图标容器 */ /* 强制隐藏搜索图标容器 */
/deep/ .uni-searchbar__box-icon-search { /deep/ .uni-searchbar__box-icon-search {
display: none !important; display: none !important;

View File

@ -0,0 +1,6 @@
## 1.0.22023-12-12
修改说明文档
## 1.0.12023-12-12
添加扫码功能
## 1.0.02023-12-12
初始化项目

View File

@ -0,0 +1,52 @@
<template>
<view>
<uni-icons @click="getScanCode" style="margin-right: 10rpx" type="scan" size="25" color="#b9bcc5"/>
<!-- <view class="getScanCode" @click="getScanCode"></view>-->
</view>
</template>
<script>
export default {
name: "yt-scanCode",
props: {
},
data() {
return {
}
},
methods: {
getScanCode() {
uni.scanCode({
onlyFromCamera: true,
scanType: ['qrCode', 'barCode', 'dataMatrix'],
success: res => {
if(res.errMsg=='scanCode:ok'){
this.$emit("getScanCode", res.result);
}
else
{
uni.showToast({
title: '扫码失败',
icon: "none",
mask: true,
})
}
},
fail: err => {
console.log(JSON.stringify(err))
}
})
},
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,86 @@
{
"id": "yt-scanCode",
"displayName": "App条形码插件支持app小程序不支持h5",
"version": "1.0.2",
"description": "yt-scanCode支持多码、相册、闪光灯、焦距缩放、提示音、震动等等。为了方便初学者快速使用。",
"keywords": [
"扫码",
"多码",
"条形码",
"app扫码",
"简单易用"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"type": "component-vue",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "u"
},
"App": {
"app-vue": "y",
"app-nvue": "y",
"app-uvue": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "n"
},
"H5-pc": {
"Chrome": "n",
"IE": "n",
"Edge": "n",
"Firefox": "n",
"Safari": "n"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y",
"钉钉": "y",
"快手": "y",
"飞书": "y",
"京东": "y"
},
"快应用": {
"华为": "y",
"联盟": "y"
}
}
}
}
}

View File

@ -0,0 +1,56 @@
# uniApp 简单的扫码功能封装
## 用法
在 template 中:
```vue
<template>
<view>
<yt-scanCode btnName="扫码按钮" @getScanCode="getScanCode"></yt-scanCode>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
getScanCode(res){
console.log("设备号======>",res);
}
}
}
</script>
<style>
</style>
```
## 属性说明
| 属性 | 是否必填 | 值类型 | 默认值 | 说明 |
| --------- | -------- | -----: | --: | :------------:|
| btnName | 否 | String |扫码 | 按钮名称 |
| `QQ交流群(906392632)` |
|<p><img align=top src="https://7072-prod-4gapv4gl33a8a0ff-1305990777.tcb.qcloud.la/%E9%87%8D%E8%A6%81%E5%9B%BE%E7%89%87%E5%AD%98%E5%82%A8/Snipaste_2023-11-06_16-50-56.png?sign=ed27f09cfeabb33e24835fecdd4108db&t=1699260686" width="500px" height="auto"></p>|
| QQ群号906392632 |
## 温馨提示
* 文件上传
0. 如说明表达还不够清楚,不清楚怎么使用可加入群聊一起交流
1. 若能帮到你还请点亮5颗小星星以作鼓励哈~
2. 若能帮到你还请点亮5颗小星星以作鼓励哈~
3. 若能帮到你还请点亮5颗小星星以作鼓励哈~