Quellcode durchsuchen

提交小程序

wang_xy vor 1 Jahr
Ursprung
Commit
3599d2f537
5 geänderte Dateien mit 228 neuen und 89 gelöschten Zeilen
  1. 9 2
      pages.json
  2. 173 0
      pages/delis.vue
  3. 45 85
      pages/index.vue
  4. 1 1
      permission.js
  5. 0 1
      utils/request.js

+ 9 - 2
pages.json

@@ -1,13 +1,20 @@
 {
 	"pages": [{
-			"path": "pages/login",
+			"path": "pages/index",
 			"style": {
 				"navigationBarTitleText": "登录",
 				"navigationStyle": "custom"
 			}
 		},
 		{
-			"path": "pages/index",
+			"path": "pages/delis",
+			"style": {
+				"navigationBarTitleText": "详情",
+				"navigationStyle": "custom"
+			}
+		},
+		{
+			"path": "pages/login",
 			"style": {
 				"navigationBarTitleText": "通知公告",
 				"navigationStyle": "custom"

+ 173 - 0
pages/delis.vue

@@ -0,0 +1,173 @@
+<template>
+	<view class="gg-container">
+		<view class="gg-tit">
+			<view class="gg-title">
+				我的吉农宝<text>上个页面传过来的参数{{id}}</text>
+			</view>
+			<view>
+			<uni-section title="基本用法" type="line">
+						<view class="example">
+							<!-- 基础用法,不包含校验规则 -->
+							<uni-forms ref="baseForm" :modelValue="baseFormData">
+								<uni-forms-item label="姓名" required>
+									<uni-easyinput v-model="baseFormData.name" placeholder="请输入姓名" />
+								</uni-forms-item>
+								<uni-forms-item label="年龄" required>
+									<uni-easyinput v-model="baseFormData.age" placeholder="请输入年龄" />
+								</uni-forms-item>
+								<uni-forms-item label="性别" required>
+									<uni-data-checkbox v-model="baseFormData.sex" :localdata="sexs" />
+								</uni-forms-item>
+								<uni-forms-item label="兴趣爱好" required>
+									<uni-data-checkbox v-model="baseFormData.hobby" multiple :localdata="hobbys" />
+								</uni-forms-item>
+								<uni-forms-item label="自我介绍">
+									<uni-easyinput type="textarea" v-model="baseFormData.introduction" placeholder="请输入自我介绍" />
+								</uni-forms-item>
+								<uni-forms-item label="日期时间">
+									<uni-datetime-picker type="datetime" return-type="timestamp" v-model="baseFormData.datetimesingle"/>
+								</uni-forms-item>
+							</uni-forms>
+						</view>
+					</uni-section>
+					<uni-section title="多行文本" subTitle="指定属性 type=textarea 使用多行文本框" type="line" padding>
+						<uni-easyinput type="textarea" v-model="value" placeholder="请输入内容"></uni-easyinput>
+					</uni-section>
+							    <!-- 这张图片就是自定义的图片,地址填写自己本地的就行 -->
+					<image src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png" 
+					mode="widthFix" style="width: 112rpx;height: 110rpx;" @click="uploadImagePhoto()"></image>
+					
+				</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				baseFormData: {
+					name: '',
+					age: '',
+					introduction: '',
+					sex: 2,
+					hobby: [5],
+					datetimesingle: 1627529992399
+				},
+				// 单选数据源
+				sexs: [{
+					text: '男',
+					value: 0
+				}, {
+					text: '女',
+					value: 1
+				}, {
+					text: '保密',
+					value: 2
+				}],
+				// 多选数据源
+				hobbys: [{
+					text: '跑步',
+					value: 0
+				}, {
+					text: '游泳',
+					value: 1
+				}, {
+					text: '绘画',
+					value: 2
+				}, {
+					text: '足球',
+					value: 3
+				}, {
+					text: '篮球',
+					value: 4
+				}, {
+					text: '其他',
+					value: 5
+				}],
+				value: '',
+				password: '',
+				placeholderStyle: "color:#2979FF;font-size:14px",
+				styles: {
+					color: '#2979FF',
+					borderColor: '#2979FF'
+				},
+				id:'',
+				fileList1: []
+			}
+
+		},
+		onLoad(options) {
+			this.id = options.id;
+		},
+		onReady() {},
+		methods: {
+			input(e) {
+				console.log('输入内容:', e);
+			},
+			iconClick(type) {
+				uni.showToast({
+					title: `点击了${type==='prefix'?'左侧':'右侧'}的图标`,
+					icon: 'none'
+				})
+			},
+			uploadImagePhoto() {
+				uni.chooseImage({
+					count: 6, //默认9
+					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
+					sourceType: ['album'], //从相册选择
+					success: function (res) {
+					}
+				});
+			},
+			// 新增图片
+			async afterRead(event) {
+				console.log(event)
+				// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
+				let lists = [].concat(event.file)
+				let fileListLen = this[`fileList${event.name}`].length
+				lists.map((item) => {
+					this[`fileList${event.name}`].push({
+						...item,
+						status: 'uploading',
+						message: '上传中'
+					})
+				})
+				for (let i = 0; i < lists.length; i++) {
+					const result = await this.uploadFilePromise(lists[i].url)
+					let item = this[`fileList${event.name}`][fileListLen]
+					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
+						status: 'success',
+						message: '',
+						url: result
+					}))
+					fileListLen++
+				}
+			},
+			//上传图片
+			uploadFilePromise(url) {
+				return new Promise((resolve, reject) => {
+					let a = uni.uploadFile({
+						//url: this.$common.domain+'/api/common/upload', // 仅为示例,非真实的接口地址
+						// url:'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
+						filePath: url,
+						name: 'file',
+						formData: {
+							user: 'test'
+						},
+						success: (res) => {
+							let data=JSON.parse(res.data) //最终传给的是字符串,这里需要转换格式
+							resolve(data.data.url)
+						}
+					});
+				})
+			}
+		}
+	}
+</script>
+
+<style scoped lang="scss">
+	.uni-mt-5 {
+		margin-top: 5px;
+	}
+</style>

+ 45 - 85
pages/index.vue

@@ -4,6 +4,30 @@
 			<view class="gg-title">
 				吉农宝
 			</view>
+			<view>
+				<uni-list>
+					<uni-list :border="true">
+						<!-- 显示圆形头像 -->
+						<uni-list-chat :avatar-circle="true" title="uni-app" avatar="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png" note="您收到一条新的消息" time="2020-02-02 20:20" ></uni-list-chat>
+						<!-- 右侧带角标 -->
+						<uni-list-chat title="uni-app" avatar="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png" note="您收到一条新的消息" time="2020-02-02 20:20" badge-text="12"></uni-list-chat>
+						<!-- 头像显示圆点 -->
+						<uni-list-chat title="uni-app" avatar="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png" note="您收到一条新的消息" time="2020-02-02 20:20" badge-positon="left" badge-text="dot"></uni-list-chat>
+						<!-- 头像显示角标 -->
+						<uni-list-chat title="uni-app" avatar="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png" note="您收到一条新的消息" time="2020-02-02 20:20" badge-positon="left" badge-text="99" to="/pages/delis?id=123"></uni-list-chat>
+						<!-- 显示多头像 -->
+						<uni-list-chat title="uni-app" :avatar-list="avatarList" note="您收到一条新的消息" time="2020-02-02 20:20" badge-positon="left" badge-text="dot"></uni-list-chat>
+						<!-- 自定义右侧内容 -->
+						<uni-list-chat title="uni-app" :avatar-list="avatarList" note="您收到一条新的消息" time="2020-02-02 20:20" badge-positon="left" badge-text="dot">
+							<view class="chat-custom-right">
+								<text class="chat-custom-text">刚刚</text>
+								<!-- 需要使用 uni-icons 请自行引入 -->
+								<uni-icons type="star-filled" color="#999" size="18"></uni-icons>
+							</view>
+						</uni-list-chat>
+					</uni-list>
+				</uni-list>
+			</view>
 		</view>
 	</view>
 </template>
@@ -12,105 +36,41 @@
 	export default {
 		data() {
 			return {
-				userInfo: {}
+				avatarList: [{
+								url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png'
+							}, {
+								url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png'
+							}, {
+								url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png'
+							}]
 			}
 		},
 		onLoad(options) {
 			this.userInfo = getApp().globalData.userInfo
 		},
 		methods: {
+			tiaozhuan(){
+				uni.navigateTo({
+					url:"/pages/delis"
+				})
+			}
 		}
 	}
 </script>
 
 <style scoped lang="scss">
-	.gg-container {
-		background-color: #fff;
-		display: flex;
-		flex-direction: column;
-	}
-
-	.gg-tit {
-		width: 100%;
-		position: relative;
-		top: 0;
-		height: 40vh;
-		display: flex;
-		justify-content: center;
-		align-items: center;
-	}
-
-	.gg-body {
-		display: flex;
-		position: absolute;
-		bottom: 25rpx;
-		width: 728rpx;
-		height: 80rpx;
-		background: linear-gradient(0deg, #90BDFF, #3F93FD, #20B9D5);
-		border-radius: 40rpx;
-		justify-content: center;
-		align-items: center;
-
-		.gg-body-tt {
-			text-align: left;
-			margin-left: 5px;
-			width: 25%;
-			display: flex;
-			align-items: center;
-			color: #FFFFFF;
-			font-weight: bold;
-			font-size: 30rpx;
-		}
-	}
-
-	.content {
+	.chat-custom-right {
+		flex: 1;
+		/* #ifndef APP-NVUE */
 		display: flex;
+		/* #endif */
 		flex-direction: column;
-		align-items: center;
-		justify-content: center;
-	}
-
-	.background {
-		border: 15px solid hsla(0, 0%, 100%, .5);
-		background: white;
-		background-clip: padding-box;
-		/*从padding开始往外面裁剪背景*/
-
-	}
-
-	.container {
-		display: flex;
-		margin-left: 10px;
-		margin-top: 10px;
-		margin-right: 10px;
-		align-items: flex-start;
 		justify-content: space-between;
+		align-items: flex-end;
 	}
-
-	.gg-title {
-		width: 100%;
-		position: absolute;
-		z-index: 1;
-		display: flex;
-		justify-content: center;
-		align-items: center;
-		font-size: 40rpx;
-		font-weight: bold;
-		color: #FFFFFF;
-	}
-
-
-
-	.notice {
-		margin: 20rpx;
-		padding: 20rpx;
-		background: #FFFFFF;
-		box-shadow: 0rpx 8rpx 17rpx 0rpx rgba(0, 0, 0, 0.04);
-		border-radius: 10rpx;
-	}
-
-	.text {
-		border-left: 15rpx solid #3857F3;
-		padding-left: 20rpx;
+	
+	.chat-custom-text {
+		font-size: 12px;
+		color: #999;
 	}
 </style>

+ 1 - 1
permission.js

@@ -5,7 +5,7 @@ const loginPage = "/pages/login"
   
 // 页面白名单
 const whiteList = [
-  '/pages/login', '/pages/index', '/pages/my'
+  '/pages/login', '/pages/index', '/pages/my','/pages/delis'
 ]
 
 // 检查地址白名单

+ 0 - 1
utils/request.js

@@ -38,7 +38,6 @@ const request = config => {
 		//console.log("dddd",res)
         const code = res.data.code || 200
         const msg = errorCode[code] || res.data.msg || errorCode['default']
-		debugger
         if (code === 401) {
           showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
             if (res.confirm) {