123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- // pages/wallet/index.js
- var AV = require('../../utils/av-weapp-min.js');
- var server = require('../../libs/config.js');
- var upload = require('../../utils/upload.js');
- var app = getApp()
- Page({
- data: {
- // 故障车周围环境图路径数组
- picUrls: [],
- // 故障车编号和备注
- inputValue: {
- num: '',
- desc: ""
- },
- // 故障类型数组
- checkboxValue: [],
- // 选取图片提示
- actionText: "拍照/相册",
- // 提交按钮的背景色,未勾选类型时无颜色
- btnBgc: "#00AA55",
- // 复选框的value,此处预定义,然后循环渲染到页面
- itemsValue: [
- {
- checked: false,
- value: "私锁私用",
- color: "#b9dd08"
- },
- {
- checked: false,
- value: "车牌缺损",
- color: "#b9dd08"
- },
- {
- checked: false,
- value: "轮胎坏了",
- color: "#b9dd08"
- },
- {
- checked: false,
- value: "车锁坏了",
- color: "#b9dd08"
- },
- {
- checked: false,
- value: "违规乱停",
- color: "#b9dd08"
- },
- {
- checked: false,
- value: "密码不对",
- color: "#b9dd08"
- },
- {
- checked: false,
- value: "刹车坏了",
- color: "#b9dd08"
- },
- {
- checked: false,
- value: "其他故障",
- color: "#b9dd08"
- }
- ]
- },
- // 页面加载
- onLoad: function (options) {
- wx.setNavigationBarTitle({
- title: '上传图片'
- })
- },
- // 勾选故障类型,获取类型值存入checkboxValue
- checkboxChange: function (e) {
- let _values = e.detail.value;
- if (_values.length == 0) {
- this.setData({
- btnBgc: ""
- })
- } else {
- this.setData({
- checkboxValue: _values,
- btnBgc: "#b9dd08"
- })
- }
- },
- // 输入单车编号,存入inputValue
- numberChange: function (e) {
- this.setData({
- inputValue: {
- num: e.detail.value,
- desc: this.data.inputValue.desc
- }
- })
- },
- // 输入备注,存入inputValue
- descChange: function (e) {
- this.setData({
- inputValue: {
- num: this.data.inputValue.num,
- desc: e.detail.value
- }
- })
- },
- // 提交到服务器
- formSubmit: function (e) {
- if (this.data.picUrls.length > 0) {
- console.log(this.data.picUrls)
- upload.uploadimg({
- url: server.Server.url + '/api/upload/batch/image',//这里是你图片上传的接口
- path: this.data.picUrls,//这里是选取的图片的地址数组,
- info: this.data.inputValue,
- userid: app.globalData.nwUserid
- });
- wx.showLoading({
- title: '上传中',
- })
- } else {
- wx.showModal({
- title: "请至少上传一张图片",
- // content: '请填反馈信息',
- confirmText: "好的",
- cancelText: "不上传了",
- success: (res) => {
- if (res.confirm) {
- // 继续填
- } else {
- console.log("back")
- wx.navigateBack({
- delta: 1 // 回退前 delta(默认为1) 页面
- })
- }
- }
- })
- }
- },
- // 选择故障车周围环境图 拍照或选择相册
- bindCamera: function () {
- wx.chooseImage({
- count: 4,
- sizeType: ['original', 'compressed'],
- sourceType: ['album', 'camera'],
- success: (res) => {
- let tfps = res.tempFilePaths;
- let _picUrls = this.data.picUrls;
- for (let item of tfps) {
- _picUrls.push(item);
- this.setData({
- picUrls: _picUrls,
- actionText: "+"
- });
- };
- var tempFilePath = res.tempFilePaths[0];
-
- }
- })
- },
- // 删除选择的故障车周围环境图
- delPic: function (e) {
- let index = e.target.dataset.index;
- let _picUrls = this.data.picUrls;
- _picUrls.splice(index, 1);
- this.setData({
- picUrls: _picUrls
- })
- }
- })
|