微信小程序——简单的售后服务单
微信小程序——简单的售后服务单
使用工具:HBuilder X、微信开发者工具
使用框架:uniapp+uview
一、数据库设计
feedback(用于存储反馈信息)
id int 11 0 0 0 -1 0 0 0 0 0 -1 0 0
userid varchar 255 0 0 0 0 0 utf8 utf8_general_ci 0 0 0 0 0 0 0
ptype varchar 255 0 0 0 0 0 utf8 utf8_general_ci 0 0 0 0 0 0 0
descr varchar 255 0 0 0 0 0 utf8 utf8_general_ci 0 0 0 0 0 0 0
comp varchar 255 0 0 0 0 0 utf8 utf8_general_ci 0 0 0 0 0 0 0
uname varchar 255 0 0 0 0 0 utf8 utf8_general_ci 0 0 0 0 0 0 0
phone varchar 255 0 0 0 0 0 utf8 utf8_general_ci 0 0 0 0 0 0 0
ftime varchar 255 0 0 0 0 0 utf8 utf8_general_ci 0 0 0 0 0 0 0
pictu(用于存储图片信息)
id int 11 0 0 0 -1 0 0 0 0 0 -1 0 0
pic varchar 255 0 -1 0 0 0 utf8 utf8_general_ci 0 0 0 0 0 0 0
time varchar 255 0 -1 0 0 0 utf8 utf8_general_ci 0 0 0 0 0 0 0
注:因为能力有限,所以只能存储图片到本地,并未将反馈图片返回到前端,并且后台只能通过时间确定pictu与feedback是否为同一条反馈
二、后端设计(springboot)
1、新建boot项目
2、配置pom.xml文件(直接复制食用,可能有些没用的)
<properties><java.version>1.8</java.version><repackage.classifier/><spring-native.version>0.10.2</spring-native.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.experimental</groupId><artifactId>spring-native</artifactId><version>${spring-native.version}</version></dependency><dependency><groupId>commons-fileupload</groupId><artifactId>commons-fileupload</artifactId><version>1.2.1</version></dependency><dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>2.5</version></dependency><!--引入druid数据源--><!-- https://mvnrepository.com/artifact/com.alibaba/druid --><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.21</version></dependency><dependency><groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.12</version></dependency><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.5.3</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.26</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version></dependency><dependency><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-core</artifactId><version>1.3.2</version></dependency><dependency><groupId>tk.mybatis</groupId><artifactId>mapper-spring-boot-starter</artifactId><version>1.1.3</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId><optional>true</optional></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-test</artifactId><version>2.1.5.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jdbc</artifactId></dependency><dependency><groupId>javax.xml.bind</groupId><artifactId>jaxb-api</artifactId><version>2.3.0</version></dependency><dependency><groupId>com.sun.xml.bind</groupId><artifactId>jaxb-impl</artifactId><version>2.3.0</version></dependency><dependency><groupId>com.sun.xml.bind</groupId><artifactId>jaxb-core</artifactId><version>2.3.0</version></dependency><dependency><groupId>javax.activation</groupId><artifactId>activation</artifactId><version>1.1.1</version></dependency><!-- 自定义配置的提示 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId><optional>true</optional></dependency><dependency><groupId>org.jetbrains</groupId><artifactId>annotations</artifactId><version>RELEASE</version><scope>compile</scope></dependency></dependencies><build><resources><resource><directory>src/main/java</directory><includes><include>**/*.xml</include><include>**/*.sql</include></includes><filtering>false</filtering></resource><resource><directory>src/main/resources</directory></resource></resources><plugins><!-- mvn mybatis-generator:generate --><plugin><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-maven-plugin</artifactId><version>1.3.2</version><configuration><verbose>true</verbose><overwrite>true</overwrite><configurationFile>src/main/resources/generatorConfig.xml</configurationFile></configuration></plugin><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><excludes><exclude><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></exclude></excludes><classifier>${repackage.classifier}</classifier><image><builder>paketobuildpacks/builder:tiny</builder><env><BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE></env></image></configuration></plugin><plugin><groupId>org.springframework.experimental</groupId><artifactId>spring-aot-maven-plugin</artifactId><version>${spring-native.version}</version><executions><execution><id>test-generate</id><goals><goal>test-generate</goal></goals></execution><execution><id>generate</id><goals><goal>generate</goal></goals></execution></executions></plugin></plugins></build><repositories><repository><id>spring-releases</id><name>Spring Releases</name><url>https://repo.spring.io/release</url><snapshots><enabled>false</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>spring-releases</id><name>Spring Releases</name><url>https://repo.spring.io/release</url><snapshots><enabled>false</enabled></snapshots></pluginRepository></pluginRepositories><profiles><profile><id>native</id><properties><repackage.classifier>exec</repackage.classifier><native-buildtools.version>0.9.1</native-buildtools.version></properties></profile></profiles>
</project>
3、新建generatorConfig.xml(resources中,用于mybatis生成dao、mapper、domain三层)
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration><classPathEntrylocation="C:\Users\chenghao\.m2\repository\mysql\mysql-connector-java\8.0.26\mysql-connector-java-8.0.26.jar" />//这个路径是你的这个jar包的本地路径,需要自己配置<context id="context1" targetRuntime="MyBatis3"><commentGenerator><property name="suppressDate" value="true"/><property name="suppressAllComments" value="true"/><property name="addRemarkComments" value="true"/></commentGenerator><jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"connectionURL="jdbc:mysql://localhost:3306/weixintest?useSSL=false& serverTimezone=Hongkong& characterEncoding=utf-8& autoReconnect=true"//里面的weixintest是我自己的数据库名,改成你的,下面的userID、password同样改成你的userId="root"password="root"/><javaTypeResolver ><property name="forceBigDecimals" value="false" /></javaTypeResolver><!--生成实体类 指定包名 以及生成的地址 (可以自定义地址,但是路径不存在不会自动创建 使用Maven生成在target目录下,会自动创建) --><javaModelGenerator targetPackage="com.ch.domain" targetProject="MAVEN"><property name="enableSubPackages" value="true" /><property name="trimStrings" value="true" /></javaModelGenerator><!--生成SQLMAP文件 --><sqlMapGenerator targetPackage="com.ch.mapper" targetProject="MAVEN" ><property name="enableSubPackages" value="false" /></sqlMapGenerator><!--生成Dao文件 可以配置 type="XMLMAPPER"生成xml的dao实现 context id="DB2Tables" 修改targetRuntime="MyBatis3" --><javaClientGenerator type="XMLMAPPER" targetPackage="com.ch.dao" targetProject="MAVEN" ><property name="enableSubPackages" value="true" /></javaClientGenerator><table tableName="feedback" enableCountByExample="false" enableUpdateByExample="false"//tableName是数据库表的名字,生成一个之后,更改这个名字,再生成另一个enableDeleteByExample="false" enableSelectByExample="false"selectByExampleQueryId="false"></table></context>
</generatorConfiguration>
4、配置Alibaba—Druid连接池
在resources中新建application.yml,里面可能有些没用的
server:port: 8090spring:datasource:username: rootpassword: rooturl: jdbc:mysql://localhost:3306/weixintest?characterEncoding=UTF-8driver-class-name: com.mysql.cj.jdbc.Drivertype: com.alibaba.druid.pool.DruidDataSourceinitialSize: 5minIdle: 5maxActive: 20maxWait: 60000timeBetweenEvictionRunsMillis: 60000minEvictableIdleTimeMillis: 300000validationQuery: SELECT 1 FROM DUALtestWhileIdle: truetestOnBorrow: falsetestOnReturn: falsepoolPreparedStatements: true#配置监控统计拦截的filters,stat:监控统计、log4j:日志记录、wall:防御sql注入#如果允许时报错 java.lang.ClassNotFoundException: org.apache.log4j.Priority#则导入 log4j 依赖即可,Maven 地址: https://mvnrepository.com/artifact/log4j/log4jfilters: stat,wall,log4jmaxPoolPreparedStatementPerConnectionSize: 20useGlobalDataSourceStat: trueconnectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500mybatis:mapper-locations:- classpath:mapper/*.xml- classpath*:com/**/mapper/*.xmltype-aliases-package: com.ch.domianconfiguration:default-statement-timeout: 100
在java包中新建druid.DruidConfig配置类(这是个类)
package com.ch.druid;import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;/*** Created by Administrator on 2018/8/20 0020.* Druid 数据源配置类*/
@Configuration
public class DruidConfig {/*** 将自定义的 Druid 数据源添加到容器中,不再让 Spring Boot 自动创建* 这样做的目的是:绑定全局配置文件中的 druid 数据源属性到 com.alibaba.druid.pool.DruidDataSource* 从而让它们生效** @return* @ConfigurationProperties(prefix = "spring.datasource"):作用就是将 全局配置文件中 前缀为 spring.datasource* 的属性值注入到 com.alibaba.druid.pool.DruidDataSource 的同名参数中*/@ConfigurationProperties(prefix = "spring.datasource")@Beanpublic DataSource druidDataSource() {return new DruidDataSource();}/*** 配置 Druid 监控 之 管理后台的 Servlet* 内置 Servler 容器时没有web.xml 文件,所以使用 Spring Boot 的注册 Servlet 方式*/@Beanpublic ServletRegistrationBean statViewServlet() {ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(),"/druid/*");/*** loginUsername:Druid 后台管理界面的登录账号* loginPassword:Druid 后台管理界面的登录密码* allow:Druid 后台允许谁可以访问* initParams.put("allow", "localhost"):表示只有本机可以访问* initParams.put("allow", ""):为空或者为null时,表示允许所有访问* deny:Druid 后台拒绝谁访问* initParams.put("deny", "192.168.1.20");表示禁止此ip访问*/Map<String, String> initParams = new HashMap<>();initParams.put("loginUsername", "admin");initParams.put("loginPassword", "123456");initParams.put("allow", "");/*initParams.put("deny", "192.168.1.20");*//** 设置初始化参数*/bean.setInitParameters(initParams);return bean;}
}
5、service层书写(只写自己要用的方法,我写了三个,不要忘记加@Service)
新建VxService接口
package com.ch.vxService;
import com.ch.domain.Feedback;
import com.ch.domain.GetFeedback;
import com.ch.domain.Pictu;
import com.ch.domain.Qcuser;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public interface VxService {int insert(Feedback record);int insert(Pictu record);List<GetFeedback> selectByUserId(String userid);
}
新建接口实现类
package com.ch.vxService.impl;
import com.ch.dao.FeedbackMapper;
import com.ch.dao.PictuMapper;
import com.ch.dao.QcuserMapper;
import com.ch.domain.Feedback;
import com.ch.domain.GetFeedback;
import com.ch.domain.Pictu;
import com.ch.domain.Qcuser;
import com.ch.vxService.VxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class VxServiceImpl implements VxService {@AutowiredFeedbackMapper feedbackMapper;@AutowiredPictuMapper pictuMapper;@Overridepublic int insert(Feedback record) {feedbackMapper.insert(record);return 1;}@Overridepublic int insert(Pictu record) {pictuMapper.insert(record);return 1;}@Overridepublic List<GetFeedback> selectByUserId(String userid) {return feedbackMapper.selectByPrimaryKey(userid);}
}
6、controller层书写(我的业务逻辑写在controller层了,一般要写在Service层,我嫌麻烦没改)
package com.ch.vxController;import com.ch.domain.Feedback;
import com.ch.domain.GetFeedback;
import com.ch.domain.Pictu;
import com.ch.domain.model;
import com.ch.utils.picUtil;
import com.ch.vxService.VxService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.stereotype.Controller;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Controller
@RestController
@ResponseBody
@SpringBootTest
@RunWith(SpringRunner.class)
public class VxController {@AutowiredVxService vxService;SimpleDateFormat f = new SimpleDateFormat("yyyy年MM月dd日-HH点mm分");public String filePath="C:/Users/chenghao/Desktop/test/"; //定义上传文件的存放位置
// @Test
// public void t(){
// SimpleDateFormat f = new SimpleDateFormat("yyyy年MM月dd日-HH点mm分");
// System.out.println(f.format(new Date()));
// }@ResponseBody@PostMapping(value = "/fb")public String putfb(@RequestBody model m){SimpleDateFormat f = new SimpleDateFormat("yyyy年MM月dd日-HH点mm分");Feedback feedback = new Feedback();feedback.setUserid(m.getUserid());feedback.setPtype(m.getPtype());feedback.setDescr(m.getIntro());feedback.setComp(m.getCompany());feedback.setUname(m.getContacts());feedback.setPhone(m.getPhone());feedback.setFtime(f.format(new Date()));vxService.insert(feedback);return feedback.toString();}@ResponseBody@PostMapping(value = "/pic")@CrossOriginpublic String putpic(@RequestParam("file") MultipartFile file){if ((file.getOriginalFilename().isEmpty())) {return "插入失败";} else {Pictu pictu = new Pictu();String fileName = file.getOriginalFilename();String fileAddress = filePath + fileName;try {picUtil.uploadFile(file.getBytes(), filePath, fileName);System.out.println(filePath);pictu.setUserid(1);pictu.setPic(fileAddress);pictu.setTime(f.format(new Date()));vxService.insert(pictu);} catch (Exception e) {e.printStackTrace();} finally {return "插入成功";}}}@ResponseBody@GetMapping(value = "/gfb")public List<GetFeedback> getFeedback(String id) {return vxService.selectByUserId(id);}
}
7、新建utils.picUtil工具类(用于接收并存储前端发送的图片)
package com.ch.utils;
import java.io.File;
import java.io.FileOutputStream;
public class picUtil {//上传文件的工具类public static void uploadFile(byte[] file, String filePath, String fileName) throws Exception {File targetFile = new File(filePath);if(!targetFile.exists()){targetFile.mkdirs();}FileOutputStream out = new FileOutputStream(filePath+fileName);out.write(file);out.flush();out.close();}
}
8、新建config.CorsConfig配置类(前后端传值可能存在跨域问题)
package com.ch.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configurationpublic
class CorsConfig implements WebMvcConfigurer {
@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") //大坑 .allowedOriginPatterns("*") .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE") .maxAge(3600) .allowCredentials(true); }}
9、新建model类(用于接收前端发来的Json格式,model类包含的属性与前端定义的相同)
private String userid;
private String ptype;
private String intro;
private String company;
private String contacts;
private String phone;
10、新建GetFeedback类(用于发送前端指定信息的类,直接将此类New的对象发送上去)
private String ftime;
private String descr;
11、修改mapper.xml中的SQL语句
添加到文件头中,这个作用是设计对象所包含的属性
<resultMap id="GetResultMap" type="com.ch.domain.GetFeedback" >
<result column="descr" property="descr" jdbcType="VARCHAR" />
<result column="ftime" property="ftime" jdbcType="VARCHAR" />
</resultMap>
查询语句:
<select id="selectByPrimaryKey" resultMap="GetResultMap" parameterType="java.lang.String" >
select descr,ftime <include refid="Base_Column_List" />
from feedback
where userid = #{id,jdbcType=VARCHAR}
</select>
12、新建log4j.properties(在resources中,不加运行时可能会报warning)
log4j.rootLogger=DEBUG, stdoutlog4j.appender.stdout=org.apache.
log4j.ConsoleAppenderlog4j.appender.stdout.layout=org.apache.
log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
13、注解书写
dao中的mapper文件:
@Repository(value = "FeedbackMapper")
@Repository(value = "PictuMapper")
主程序中:
@SpringBootApplication
@MapperScan("com.ch.dao")
三、前端设计
不多逼逼直接四个界面代码
pages/center/index.vue
{{pic}} {{nickName}}
pages/index/index.vue
pages/login/test.vue
你好 今天又是充满希望的一天
pages/query/myQuery.vue
{{pic}} {{ res.ftime }} {{res.descr}}
pages.json
“pages”: [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
“path”: “pages/login/test”,
“style”: {
“navigationBarTitleText”: “登录”
}
},
{
“path”: “pages/index/index”,
“style”: {
“navigationBarTitleText”: “客户售后反馈”
}
},
{
“path”: “pages/center/index”,
“style”: {
“navigationBarTitleText”: “个人中心”
}
},
{
“path”: “pages/query/myQuery”,
“style”: {
“navigationBarTitleText”: “我的问题”
}
}
]
main.js
import Vue from ‘vue’
import App from ‘./App’
// 引入全局uView
import uView from ‘uview-ui’
import axios from ‘./utils/request/request.js’
import WXBizDataCrypt from ‘@/static/WXBizDataCrypt.js’;
//WXBizDataCrypt.js官网的工具包
Vue.use(uView);
Vue.config.productionTip = false
Vue.prototype.$axios = axios
App.mpType = ‘app’
const app = new Vue({
…App
})
app.$mount()
app.vue
微信小程序——简单的售后服务单相关推荐
- 微信小程序简单的信息表格的提交到数据库(新手篇)(云端数据库)
微信小程序简单的信息表格的提交到数据库(新手专属)(云端数据库) 大家好,我是小陈,一名大一的编码爱好者,,,,,刚刚结束了大一的学习生活,也总结出了一点编码的经验,希望与大家一起分享.我是学习物联网 ...
- 微信小程序的动态表单,实现房屋租赁的多租客录入
0 前言 本文将介绍如何使用微信小程序编写动态表单,最终实现房屋租赁系统中多租客录入的业务. 在阅读本文前,您需要对微信小程序的开发有一个初步的了解,以便更容易的学会开发动态表单. 作者主页:Desi ...
- 小程序 微信统计表格_微信小程序简单的数据表格及查询功能
简介: 此项目是一个前后端分离的小demo, 开发工具:idea+微信小程序开发工具 前端:界面布局样式和js的跳转 后端:依靠SpringBoot的业务逻辑层 项目的码云地址: 微信开发工具的使用和 ...
- 微信小程序简单好看的表格器
微信小程序简单好看的表格 1.数据和样式 2.带纵向滑动条的列表纯色简单表格 3.带纵向滑动条的列表间隔色简单表格 微信小程序目前没有 table 标签,需要用到表格,必须自己处理.想要一个简单的比较 ...
- 第十五周——微信小程序简单的界面
第十五周--微信小程序简单的界面 前言 一.Pages 二.TabBar 总结 前言 本篇文章是向大家分享一下怎样简单制作一个微信小程序的界面 一.Pages 这里要写的是小程序里面你所创建界面的路径 ...
- 基于微信小程序的奶茶点单系统设计与实现-计算机毕业设计源码+LW文档
奶茶点单小程序 摘 要 随着Internet的发展,人们的日常生活已经离不开网络.未来人们的生活与工作将变得越来越数字化.网络化和电子化.本文以实际运用为开发背景,运用软件工程原理和开发方法,它主要 ...
- 微信小程序--简单页面跳转
微信小程序--简单页面跳转 例如:点击一个text ,跳转入一个新的页面blueberry.wxml 首先对text 设置监听事件 <view bindtap="toast" ...
- 【微信小程序系列】微信小程序简单的实现发送订阅信息
[微信小程序系列]微信小程序简单的实现发送订阅信息 项目结构 两个云函数一个页面 获取模板 注:详细内容中的参数很重要,一会要在云函数里用 代码 app.js // app.js App({onLau ...
- 计算机毕业设计ssm+vue基本微信小程序的奶茶点单系统
随着我国经济迅速发展,人们对手机的需求越来越大,各种手机软件也都在被广泛应用,但是对于手机进行数据信息管理,对于手机的各种软件也是备受客户的喜爱,随便点奶茶点单小程序被客户普遍使用,为方便客户能够可以 ...
- 微信小程序简单日历组件
微信小程序简单的日历组件 代码: <!--日历组件--> <view class='cld'><view class="cld-top">< ...
最新文章
- [转]项目经理面试指南
- 解决Linux下动态链接库失败的问题
- app登录界面背景 css_计算机毕业设计中Java web实现简登录页面(MyBatis+jsp+servlet+html+css+javascript)...
- 机器学习实现计算不规则图形面积_谷歌开源 TensorFlow Graphics:专为 3D 图像打造的深度学习利器...
- Codeforces Round #179 (Div. 2): D. Greg and Graph(Floyd)
- JConsole可视化工具介绍
- 经典回味:ResNet到底在解决一个什么问题呢?
- K8s系列之:网络原理
- 学习编程,应该从哪里开始学习呢?
- 逻辑漏洞之无密码登录(vlcms)
- 英语学习的几个实用网站
- 思科模拟器实验6:rip基础配置
- java大数据量调优(超赞值得收藏)
- 日志采集系统都用到哪些技术?
- oracle 考试通过说考试作弊,这些行为很有可能会被判定为作弊!一定要小心!...
- Linux下for语句
- 实例学习ansible系列(12)常用模块之docker
- jsp+servlet实现简单登录页面功能Demo
- 2022年5月、11月网络工程师真题详解
- github能ping通但是打不开网页