Commit 7e26ce86 by 杨子

提交

parent d6cd31a4
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
})
const db = cloud.database();
// 云函数入口函数
exports.main = async(event, context) => {
switch (event.action) {
case 'addCart':
{
return addCart(event)
}
case 'updateCart':
{
return updateCart(event)
}
case 'deleteCartOne':
{
return deleteCartOne(event)
}
case 'deleteAllCart':
{
return deleteAllCart(event)
}
case 'findAll':
{
return findAll(event)
}
default:
{
return
}
}
}
/**
* 购物车信息
* 购物车Id,_openid,cart_count,cart_price,foodList
*/
/**
* 添加购物车
* 参数 食品的id、添加的食品数量
* 1、查询购物车信息
* 2、根据食品id查询食品对象
* 3、根据新添加的食品数量 和单价,和购物车信息计算出新的购物车信息并保存在数据库
*/
async function addCart(event) {
const {
OPENID
} = cloud.getWXContext();
const cartResult = await findAll();
const food = await getFood(event);
const newCart = {};
let isAdd = true;
//更新购物车中食品信息
console.log(cartResult);
if (cartResult.data && cartResult.data.length !== 0) { // 如果查询出购物车信息
const foodList = cartResult.data[0].foodList; // 查询购物车中食品信息
if (foodList && foodList.length !== 0) { // 如果购物车中有食品信息
foodList.push({ ...food,
out_count: event.out_count
}); // 将当前食品添加到购物车中,并更新out_put属性
newCart.foodList = foodList;
}
} else {
isAdd = true;
newCart.foodList = [{ ...food,
out_count: event.out_count
}];
}
newCart.cart_count = newCart.foodList.reduce((total, num) => {
return total + num.out_count
}, 0)
newCart.cart_price = newCart.foodList.reduce((total, num) => {
return total + num.price * num.out_count
}, 0)
try {
const result = await db.collection('cart').doc(String(OPENID)).set({
data: {
"_openid": OPENID,
...newCart
}
})
if (result.errMsg == 'document.set:ok') {
return {
code: 1,
data: null,
msg: '添加成功'
}
}
return {
code: 1,
data: null,
msg: '添加失败'
}
} catch (e) {
return {
code: 1,
data: null,
msg: '添加失败'
}
}
}
/**
* 更新购物车,参数包含购物车cartId,食品foodId,out_count
*/
async function updateCart(event) {
// 1、根据id查询出购物车信息
let cart = await db.collection('cart').doc(event.cartId).get();
let newCart = {};
newCart.foodList = cart.data.foodList.map(val => {
if (val._id == event.foodId) {
val.out_count = event.out_count;
}
return val;
})
newCart.cart_count = newCart.foodList.reduce((total, num) => {
return total + num.out_count
}, 0)
newCart.cart_price = newCart.foodList.reduce((total, num) => {
return total + num.price * num.out_count
}, 0)
try {
const result = await db.collection('cart').doc(event.cartId).update({
data: {
...newCart
}
});
if (result.errMsg == 'document.update:ok' && result.stats.updated == 1) {
return {
code: 1,
data: null,
msg: '更新成功'
}
}
return {
code: 0,
data: null,
msg: '更新失败'
}
} catch (e) {
return {
code: 0,
data: null,
msg: '更新失败'
}
}
}
/**
* 删除一个食品
* 参数购物车cartId,食品foodId,当购物车中foodList 为空的时候,删除整个购物车
*/
async function deleteCartOne(event) {
try {
// 先匹配购物车中foodlist数量,如果foodlist有且只有一条信息,直接删除整个购物车,否则只删除其中一个食品信息
let cart = await db.collection('cart').doc(event.cartId).get();
let newFoodList = cart.data.foodList.filter(val => val._id !== event.foodId);
let result = null;
console.log(newFoodList);
if (newFoodList.length == 0) {
result = await db.collection('cart').doc(event.cartId).remove();
} else {
// 更新购物车信息
let newCart = {};
newCart.foodList = newFoodList;
newCart.cart_count = newCart.foodList.reduce((total, num) => {
return total + num.out_count
}, 0)
newCart.cart_price = newCart.foodList.reduce((total, num) => {
return total + num.price * num.out_count
}, 0)
result = await db.collection('cart').doc(event.cartId).update({
data: {
...newCart
}
})
}
console.log(result);
if (result.errMsg == 'document.remove:ok' && result.stats.removed == 1) {
return {
code: 1,
data: null,
msg: '删除成功'
}
}
if (result.errMsg == 'document.update:ok' && result.stats.updated == 1) {
return {
code: 1,
data: null,
msg: '删除成功'
}
}
return {
code: 0,
data: null,
msg: '删除失败'
}
} catch (e) {
return {
code: 0,
data: null,
msg: '删除失败'
}
}
}
async function deleteAllCart(event) {
try {
const result = await db.collection('cart').doc(event.cartId).remove();
console.log(result);
if (result.errMsg == 'document.remove:ok' && result.stats.removed > 0) {
return {
code: 1,
data: null,
msg: '删除成功'
}
}
return {
code: 0,
data: null,
msg: '删除失败'
}
} catch (e) {
return {
code: 0,
data: null,
msg: '删除失败'
}
}
}
/**
* 查询出购物车信息
*/
async function findAll() {
const {
OPENID
} = cloud.getWXContext();
try {
const result = await db.collection('cart').where({
"_openid": OPENID
}).get();
console.log(result);
if (result.errMsg == 'collection.get:ok') {
return {
code: 1,
data: result.data,
msg: '查询成功'
}
}
return {
code: 0,
data: null,
msg: '查询失败'
}
} catch (e) {
return {
code: 0,
data: null,
msg: '查询失败'
}
}
}
/**
* 调用foodlist云函数 查询出当前食品对象
*/
async function getFood(event) {
const food = await cloud.callFunction({
name: 'foodList',
data: {
action: 'find',
"_id": event.foodId
}
})
console.log(food);
return food.result.data;
}
\ No newline at end of file
{
"name": "cart",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "latest"
}
}
\ No newline at end of file
......@@ -21,6 +21,9 @@ exports.main = async (event, context) => {
case 'find': {
return findCategory(event)
}
case 'findCategoryById':{
return findCategoryById(event)
}
default: {
return
}
......@@ -33,6 +36,7 @@ async function addCategory(event){
data:{
category_type:event.category_type,
name:event.name,
order:event.order,
create_time:new Date()
}
});
......@@ -130,4 +134,28 @@ async function findCategory(event) {
msg: "查询失败"
}
}
}
async function findCategoryById(event) {
try {
const result = await db.collection('foodCategory').doc(event._id).get();
if (result.errMsg == 'document.get:ok') {
return {
code: 1,
data: result.data,
msg: "查询成功"
}
}
return {
code: 0,
data: null,
msg: "查询失败"
}
} catch (e) {
return {
code: 0,
data: null,
msg: "查询失败"
}
}
}
\ No newline at end of file
......@@ -36,24 +36,16 @@ exports.main = async (event, context) => {
* 添加一条食品信息
*/
async function addFood(event){
const wxContext = cloud.getWXContext()
const userIds = await db.collection('user').where({
_openid: wxContext.OPENID
}).field({
_id:true
}).get()
console.log(userIds)
try{
const result = await db.collection('food').add({
data: {
food_name: event.name,
food_price: event.price,
food_desc: event.desc,
food_order: event.order,
name: event.name,
price: Number(event.price),
desc: event.desc,
order: Number(event.order),
category_type: event.category_type,
food_imgs: event.img,
create_user: userIds.data[0]._id,
img: event.img,
out_count:0,
create_time: new Date()
}
})
......@@ -112,12 +104,12 @@ async function editFood(event) {
try {
const result = await db.collection('food').doc(event._id).update({
data:{
food_name: event.name,
foodPrice: event.price,
food_desc: event.desc,
food_order: event.order,
name: event.name,
price: Number(event.price),
desc: event.desc,
order: Number(event.order),
category_type: event.category_type,
food_imgs: event.img,
img: event.img,
update_time: new Date()
}
});
......@@ -148,7 +140,6 @@ async function editFood(event) {
async function findFood(event) {
try {
const result = await db.collection('food').doc(event._id).get();
console.log(result)
if (result.errMsg == 'document.get:ok') {
return {
code: 1,
......
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database();
// 云函数入口函数
exports.main = async (event, context) => {
switch (event.action) {
case 'addOrder': {
return addOrder(event)
}
case 'updateOrder': {
return updateOrder(event)
}
case 'findAllOrderList':{
return findAllOrderList(event)
}
case 'findOrderDetail':{
return findOrder(event)
}
default: {
return
}
}
}
async function addOrder(event){
const wxContext = cloud.getWXContext()
const OPENID= wxContext.OPENID;
const orderNo = await createOrderNo();
// 添加订单
/**
* 将食品添加到订单中,更新order表
*/
const result = await db.collection('order').add({
data:{
_openid:OPENID,
orderNo,
order_amount: event.order_amount,
order_state:0, // 0 表示未完成 1表示已完成 2表示已取消
pay_mode:1, // 默认微信支付
pay_state:0, // 0待付款 1、已付款
phone:event.phone,
remark:event.remark,
take_food_time:event.
}
})
}
/**
* 生产订单编号
*/
async function createOrderNo(){
//1、获取数据库中所有订单的单号,进行排序
//2、判断如果有单号,取出最后一个单号,否则赋值
//3、用substr方法截取出除了时间后的字符串转为数字
//4、将该数字自增,转为字符串
//5、生成单号
const result = await db.collection('order').field({
orderNo:true
}).orderBy('orderNo','asc').get();
let orderNo = null;
if(result.errMsg == 'collection.get:ok'){
if(result.data.length ==0){
orderNo = 'DC'+ new Date().getTime()+'100';
}else{
const len = result.data.length;
const lastOrderNo = result.data[len-1];// 最大单号
const num = lastOrderNo.substr(15,3);
num++;
orderNo = 'DC'+new Date().getTime()+num;
}
}
return orderNo;
}
\ No newline at end of file
{
"name": "order",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "latest"
}
}
\ No newline at end of file
......@@ -26,9 +26,6 @@ async function editShop(event){
data:{
name:event.name,
phone:event.phone,
province:event.province,
city:event.city,
district:event.district,
address:event.address,
location:event.location,
introduction:event.introduction,
......@@ -36,13 +33,18 @@ async function editShop(event){
logo:event.logo
}
})
console.log(result);
if(result.errMsg == 'document.update:ok'){
return {
code:1,
data:null,
msg:'更新成功'
const shop = await findShop();
console.log(shop);
if(shop.code == 1){
return {
code: 1,
data: shop.data,
msg: '更新成功'
}
}
}
return {
......@@ -64,7 +66,6 @@ async function findShop(event) {
const id = 'f3e016cd-9874-4ea8-a905-2dc4423c4723';
try{
const result = await db.collection('shop').doc(id).get();
console.log(result);
if (result.errMsg == 'document.get:ok'){
return {
code:1,
......
......@@ -20,7 +20,8 @@ App({
WINDOWWIDTH: wx.getSystemInfoSync().windowWidth,
WINDOWHEIGHT: wx.getSystemInfoSync().windowHeight,
userInfo: null,
isLogin:false
isLogin:false,
categories:[]
}
},
......@@ -45,11 +46,39 @@ App({
}
})
},
chooseLocation() {
/**
* 选择定位信息
*/
chooseLocation(params,callback={}) {
wx.chooseLocation({
latitude: params.latitude,
longitude: params.longitude,
success: function(res) {
console.log(res);
if (res.errMsg == 'chooseLocation:ok'){
if(typeof callback.success == 'function') callback.success(res);
}
},
fail(){
if (typeof callback.fail == 'function') callback.fail();
}
})
},
getCategories(){
const that = this;
wx.cloud.callFunction({
name: 'categories',
data: {
action: 'find'
},
success(res) {
if (res.result.code == 1) {
that.globalData.categories = res.result.data;
wx.setStorageSync('categories', that.globalData.categories);
}
},
fail() {
console.log('查询分类失败');
}
})
},
getShopInfo(callback) {
......@@ -108,6 +137,7 @@ App({
if (res.result.code == 1) {
that.globalData.userInfo = res.result.data;
wx.setStorageSync('userInfo', res.result.data);
that.getCategories();
that.globalData.isLogin = true;
wx.navigateTo({
url: '../index/index'
......
......@@ -26,7 +26,8 @@
"pages/admin/editFood/editFood",
"pages/admin/categoryList/categoryList",
"pages/admin/addCategory/addCategory",
"pages/admin/shopInfo/shopInfo"
"pages/admin/shopInfo/shopInfo",
"pages/admin/editCategory/editCategory"
],
"window": {
"backgroundColor": "#F6F6F6",
......
......@@ -65,4 +65,18 @@ background: transparent;
color: #fff;
line-height: 50px;
padding: 0;
}
.interval-box{
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: flex-end;
}
.interval-box image{
width:26px;
height: 26px;
}
.interval-box .num{
padding:0 6px;
font-size: 18px;
}
\ No newline at end of file
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1575270824306" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1898" width="48" height="48" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><style type="text/css"></style></defs><path d="M958.660364 288.642956l0.024559 0L511.996418 65.304332 66.119395 288.23568l-0.830925 0L65.28847 735.350904l446.707948 223.344764 446.714088-223.344764L958.710506 288.642956 958.660364 288.642956 958.660364 288.642956 958.660364 288.642956zM511.996418 119.41267l335.906399 168.380942-127.914298 64.48671L382.46939 184.402847 511.996418 119.41267 511.996418 119.41267 511.996418 119.41267zM323.935252 216.08543l341.852832 164.712389-153.816225 74.501808L176.095135 288.642956 323.935252 216.08543 323.935252 216.08543 323.935252 216.08543zM121.126196 345.139691l17.753339 0-17.753339-0.652869 0-27.915793L484.086765 498.05643l0 390.871245L121.126196 707.446367 121.126196 345.139691 121.126196 345.139691 121.126196 345.139691zM902.86664 372.414895l0 335.031473L539.905048 888.927675 539.905048 498.05643 902.86664 316.571029 902.86664 372.414895 902.86664 372.414895 902.86664 372.414895z" p-id="1899" fill="#8a8a8a"></path></svg>
\ No newline at end of file
......@@ -7,7 +7,50 @@ Page({
data: {
},
formSubmit(e){
const value = e.detail.value;
const that = this;
wx.showLoading({
title: '正在保存...',
})
wx.cloud.callFunction({
name:'categories',
data:{
name: value.name,
category_type:value.category_type,
order:value.order,
action:'add'
},
success(res){
if(res.result.code == 1){
wx.showToast({
title: '保存成功',
success() {
that.setData({
category:{
name:'',
order:null,
category_type:null
}
})
}
})
}
},
fail(){
wx.showToast({
title: '保存失败',
icon:"fail"
})
},
complete(){
wx.hideLoading();
}
})
},
formReset: function () {
console.log('form发生了reset事件')
},
/**
* 生命周期函数--监听页面加载
*/
......
<!--miniprogram/pages/admin/addCategory/addCategory.wxml-->
<!--miniprogram/pages/admin-foodList/addFood/addFood.wxml-->
<form bindsubmit="formSubmit">
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">分类名称</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" name="name" placeholder="请输入食品名称" />
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">食品价格</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" name="price" placeholder="请输入食品价格" />
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">食品描述</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" name="desc" placeholder="请输入食品描述" />
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">排序</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" name="order" placeholder="请输入排序" />
</view>
</view>
<view class="weui-cell weui-cell_select">
<view class="weui-cell__hd weui-cell__hd_in-select-after">
<view class="weui-label" style="padding-left:16px;">选择食品分类</view>
</view>
<view class="weui-cell__bd">
<picker bindchange="bindCountryChange" name="category_type" value="{{countryIndex}}" range="{{countries}}">
<view class="weui-select weui-select_in-select-after">{{countries[countryIndex]}}</view>
</picker>
<form bindsubmit="formSubmit" bindreset="formReset">
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">分类名称</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" value="{{category.name}}" name="name" placeholder="请输入分类名称" />
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">分类编号</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" value="{{category.category_type}}" type="number" name="category_type" placeholder="请输入分类编号" />
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">排序</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" value="{{category.order}}" type="number" name="order" placeholder="请输入排序" />
</view>
</view>
</view>
<view class="weui-cells">
<view class="weui-cell">
<view class="weui-cell__bd">
<view class="weui-uploader">
<view class="weui-uploader__hd">
<view class="weui-uploader__overview">
<view class="weui-uploader__title">图片上传</view>
<view class="weui-uploader__info">{{files.length}}/2</view>
</view>
<view class="weui-uploader__tips">
上传提示
</view>
</view>
<view class="weui-uploader__bd">
<view class="weui-uploader__files" id="uploaderFiles">
<block wx:for="{{files}}" wx:key="*this">
<view class="weui-uploader__file" bindtap="previewImage" id="{{item}}">
<image class="weui-uploader__img" src="{{item}}" mode="aspectFill" />
</view>
</block>
<!-- <view class="weui-uploader__file weui-uploader__file_status">
<image class="weui-uploader__img" src="../images/pic_160.png" mode="aspectFill" />
<view class="weui-uploader__file-content">
<view class="weui-loading"></view>
</view>
</view>
<view class="weui-uploader__file weui-uploader__file_status">
<image class="weui-uploader__img" src="../images/pic_160.png" mode="aspectFill" />
<view class="weui-uploader__file-content">
<icon type="warn" size="23" color="#F43530"></icon>
</view>
</view>
<view class="weui-uploader__file weui-uploader__file_status">
<image class="weui-uploader__img" src="../images/pic_160.png" mode="aspectFill" />
<view class="weui-uploader__file-content">50%</view>
</view> -->
</view>
<view class="weui-uploader__input-box">
<view class="weui-uploader__input" bindtap="doUpload"></view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="footer">
<button class="btn_login" formType="submit">保存</button>
<button class="btn_login" formType="submit">保存</button>
</view>
</form>
</form>
\ No newline at end of file
......@@ -5,35 +5,33 @@ Page({
* 页面的初始数据
*/
data: {
files: []
files: [],
categories: []
},
// 上传图片
doUpload: function () {
doUpload: function() {
var that = this;
// 选择图片
wx.chooseImage({
count: 1,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
success: function(res) {
wx.showLoading({
title: '上传中',
})
const filePath = res.tempFilePaths[0]
const filePath = res.tempFilePaths[0];
console.log(filePath)
// 上传图片
const cloudPath = 'my-image' + filePath.match(/\.[^.]+?$/)[0]
const cloudPath = 'product-' + new Date().getTime() + filePath.match(/\.[^.]+?$/)[0]
wx.cloud.uploadFile({
cloudPath,
filePath,
success: res => {
console.log('[上传文件] 成功:', res)
// app.globalData.fileID = res.fileID
// app.globalData.cloudPath = cloudPath
// app.globalData.imagePath = filePath
that.files = [res.fileID];
that.setData({
files: [res.fileID]
});
......@@ -58,73 +56,171 @@ Page({
})
},
previewImage: function (e) {
wx.previewImage({
current: e.currentTarget.id, // 当前显示图片的http链接
urls: [e.currentTarget.id] // 需要预览的图片http链接列表
previewImage: function(e) {
this.setData({
show: true,
currentIndex: 0
})
},
/**
* 保存食品
*/
formSubmit(e){
formSubmit(e) {
console.log(e);
const value = e.detail.value;
const that = this;
var params = {
action: 'add',
name: value.name,
price: value.price,
desc: value.desc,
order: value.order,
category_type: this.categories.find((val, index) => index == value.categoryIndex).category_type,
img: this.files[0]
}
wx.showLoading({
title: '正在添加...',
})
wx.cloud.callFunction({
name: 'foodList',
data: params,
success(res) {
if (res.result.code == 1) {
wx.showToast({
title: '添加成功',
success() {
that.setData({
food: {},
categoryIndex: null,
files: []
})
}
})
}
},
fail() {
wx.showToast({
title: '添加失败',
icon: 'fail'
})
},
complete() {
wx.hideLoading();
}
})
},
/**
* 生命周期函数--监听页面加载
* 获取食品分类
*/
onLoad: function (options) {
getCategories() {
var result = wx.getStorageSync('categories');
this.categories = result;
this.setData({
categories: result,
categoryIndex: 0
})
},
bindCategoryChange(e) {
console.log(e);
var index = e.detail.value;
this.setData({
categoryIndex: index
})
},
change(e) {
console.log('current index has changed', e.detail)
},
deleteImg(e) {
console.log('delete', e.detail.url)
const that = this;
wx.cloud.deleteFile({
fileList: [e.detail.url],
success: res => {
// handle success
console.log(res.fileList)
wx.showToast({
icon: 'none',
title: '删除成功',
})
that.files = that.files.filter(v => v !== e.detail.url);
that.setData({
files: that.files
})
},
fail: err => {
wx.showToast({
icon: 'none',
title: '删除失败',
})
},
complete: res => {
}
})
},
hide() {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.getCategories();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
}
})
\ No newline at end of file
{
"usingComponents": {}
"usingComponents": {
"mp-gallery": "../components/gallery/gallery"
}
}
\ No newline at end of file
<!--miniprogram/pages/admin-foodList/addFood/addFood.wxml-->
<form bindsubmit="formSubmit">
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">食品名称</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">食品名称</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" value="{{food.name}}" name="name" placeholder="请输入食品名称" />
</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" name="name" placeholder="请输入食品名称" />
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">食品价格</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" type="number" value="{{food.price}}" name="price" placeholder="请输入食品价格" />
</view>
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">食品价格</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" name="price" placeholder="请输入食品价格" />
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">食品描述</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" value="{{food.desc}}" name="desc" placeholder="请输入食品描述" />
</view>
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">食品描述</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">排序</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" type="number" value="{{food.order}}" name="order" placeholder="请输入排序" />
</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" name="desc" placeholder="请输入食品描述" />
<view class="weui-cell weui-cell_select">
<view class="weui-cell__hd weui-cell__hd_in-select-after">
<view class="weui-label" style="padding-left:16px;">选择食品分类</view>
</view>
<view class="weui-cell__bd">
<picker bindchange="bindCategoryChange" name="categoryIndex" value="{{categoryIndex}}" range="{{categories}}" range-key="name">
<view class="weui-select weui-select_in-select-after">{{categories[categoryIndex].name}}</view>
</picker>
</view>
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">排序</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" name="order" placeholder="请输入排序" />
</view>
</view>
<view class="weui-cell weui-cell_select">
<view class="weui-cell__hd weui-cell__hd_in-select-after">
<view class="weui-label" style="padding-left:16px;">选择食品分类</view>
</view>
<view class="weui-cell__bd">
<picker bindchange="bindCountryChange" name="category_type" value="{{countryIndex}}" range="{{countries}}">
<view class="weui-select weui-select_in-select-after">{{countries[countryIndex]}}</view>
</picker>
</view>
</view>
<view class="weui-cells">
<view class="weui-cell">
<view class="weui-cell__bd">
<view class="weui-uploader">
<view class="weui-uploader__hd">
<view class="weui-uploader__overview">
<view class="weui-uploader__title">图片上传</view>
<view class="weui-uploader__info">{{files.length}}/2</view>
</view>
<view class="weui-uploader__tips">
上传提示
</view>
</view>
<view class="weui-uploader__bd">
<view class="weui-uploader__files" id="uploaderFiles">
<block wx:for="{{files}}" wx:key="*this">
<view class="weui-uploader__file" bindtap="previewImage" id="{{item}}">
<image class="weui-uploader__img" src="{{item}}" mode="aspectFill" />
</view>
</block>
<!-- <view class="weui-uploader__file weui-uploader__file_status">
<image class="weui-uploader__img" src="../images/pic_160.png" mode="aspectFill" />
<view class="weui-uploader__file-content">
<view class="weui-loading"></view>
</view>
</view>
<view class="weui-uploader__file weui-uploader__file_status">
<image class="weui-uploader__img" src="../images/pic_160.png" mode="aspectFill" />
<view class="weui-uploader__file-content">
<icon type="warn" size="23" color="#F43530"></icon>
</view>
</view>
<view class="weui-uploader__file weui-uploader__file_status">
<image class="weui-uploader__img" src="../images/pic_160.png" mode="aspectFill" />
<view class="weui-uploader__file-content">50%</view>
</view> -->
</view>
<view class="weui-uploader__input-box">
<view class="weui-uploader__input" bindtap="doUpload"></view>
</view>
</view>
</view>
</view>
<view class="weui-cells">
<view class="weui-cell">
<view class="weui-cell__bd">
<view class="weui-uploader">
<view class="weui-uploader__hd">
<view class="weui-uploader__overview">
<view class="weui-uploader__title">图片上传</view>
<view class="weui-uploader__info">{{files.length}}/2</view>
</view>
<view class="weui-uploader__tips">
上传提示
</view>
</view>
<view class="weui-uploader__bd">
<view class="weui-uploader__files" id="uploaderFiles">
<block wx:for="{{files}}" wx:key="*this">
<view class="weui-uploader__file" bindtap="previewImage" id="{{item}}">
<image class="weui-uploader__img" src="{{item}}" mode="aspectFill" />
</view>
</block>
</view>
<view class="weui-uploader__input-box">
<view class="weui-uploader__input" bindtap="doUpload"></view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="footer">
<button class="btn_login" formType="submit">保存</button>
<button class="btn_login" formType="submit">保存</button>
</view>
</form>
\ No newline at end of file
</form>
<mp-gallery show="{{show}}" bindchange="change" binddelete="delete" bindhide="hide" img-urls="{{files}}" delete hide-on-click="{{true}}" current="{{currentIndex}}"></mp-gallery>
\ No newline at end of file
......@@ -5,7 +5,7 @@ Page({
* 页面的初始数据
*/
data: {
categories:[]
},
/**
......@@ -14,9 +14,6 @@ Page({
onLoad: function (options) {
this.setData({
slideButtons: [{
text: '预览',
src: '/images/svg/view.svg', // icon的路径
}, {
type: 'primary',
text: '编辑',
extClass: 'test',
......@@ -28,27 +25,109 @@ Page({
src: '/images/svg/delete.svg', // icon的路径
}],
});
},
slideButtonTap(e) {
console.log('slide button tap', e.detail)
console.log('slide button tap', e)
var id = e.currentTarget.dataset.id;
if(e.detail.index == 0){ // 编辑
this.editCate(id);
}else if(e.detail.index == 1){ //删除
this.delCate(id);
}
},
goAdd() {
wx.navigateTo({
url: '../addCategory/addCategory',
})
},
delCate(id){
const that = this;
wx.showModal({
title: '确认删除吗',
success(){
wx.cloud.callFunction({
name:'categories',
data:{
action:'del',
"_id":id
},
success(res){
if(res.result.code == 1){
wx.showToast({
title: res.result.msg,
success(){
const result = that.categories.filter(val => val._id !== id);
that.setData({
categories: result
})
wx.setStorageSync('categories', result);
}
})
}
},
fail(){
wx.showToast({
title: '删除失败',
icon:'fail'
})
}
})
}
})
},
editCate(id){
wx.navigateTo({
url: '../editCategory/editCategory?id='+id,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
getCategories(){
const that = this;
wx.showLoading({
title: '正在加载',
})
wx.cloud.callFunction({
name: 'categories',
data: {
action: 'find'
},
success(res) {
console.log(res)
if (res.result.code == 1) {
that.categories = res.result.data;
wx.setStorageSync('categories', that.categories);
that.setData({
categories: that.categories
})
}
},
fail() {
wx.showToast({
title: '加载失败',
icon: 'fail'
})
},
complete() {
wx.hideLoading();
}
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getCategories();
},
/**
......
{
"usingComponents": {}
"usingComponents": {
"mp-cells": "../components/cells/cells",
"mp-cell": "../components/cell/cell",
"mp-slideview": "../components/slideview/slideview"
}
}
\ No newline at end of file
......@@ -2,19 +2,17 @@
<!--miniprogram/pages/admin-foodList/admin-foodList.wxml-->
<view class="page">
<view class="weui-slidecells">
<mp-slideview buttons="{{slideButtons}}" icon="{{true}}" bindbuttontap="slideButtonTap">
<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<image class="weui-media-box__thumb" src="{{icon60}}" />
</view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">标题二</view>
<view class="weui-media-box__desc">由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。</view>
</view>
</navigator>
</mp-slideview>
<block wx:for="{{categories}}" wx:key="item">
<mp-slideview buttons="{{slideButtons}}" icon="{{true}}" data-id="{{item._id}}" bindbuttontap="slideButtonTap">
<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">{{item.name}}</view>
</view>
</navigator>
</mp-slideview>
</block>
</view>
<view class="footer" bindtap="goAdd">
<text>新增</text>
</view>
</view>
</view>
\ No newline at end of file
/* miniprogram/pages/admin/categoryList/categoryList.wxss */
\ No newline at end of file
/* miniprogram/pages/admin/categoryList/categoryList.wxss */
.weui-media-box {
background: #fff;
}
mp-slideview{
margin: 8px 0;
display: block;
}
\ No newline at end of file
// miniprogram/pages/admin/editCategory/editCategory.js
Page({
/**
* 页面的初始数据
*/
data: {
category:null
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options);
var id = options.id;
this.getCategory(id);
},
getCategory(id){
const that = this;
wx.showLoading({
title: 'loading...',
})
wx.cloud.callFunction({
name:'categories',
data:{
action:'findCategoryById',
"_id":id
},
success(res){
if(res.result.code == 1){
const category = res.result.data;
that.category = category;
that.setData({
category: category
})
}
},
fail(){
wx.showToast({
title: '获取失败',
})
},
complete(){
wx.hideLoading();
}
})
},
formSubmit(e){
var result = e.detail.value;
wx.showLoading({
title: '正在更新...',
});
wx.cloud.callFunction({
name:'categories',
data:{
action:'edit',
"_id": this.category._id,
name:result.name,
category_type:result.category_type,
order:result.order
},
success(res){
if(res.result.code == 1){
wx.showToast({
title: res.result.msg,
success(){
wx.navigateBack();
}
})
}
},
fail(){
wx.showToast({
title: '更新失败',
icon:'fail'
})
},
complete(){
wx.hideLoading()
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<form bindsubmit="formSubmit" bindreset="formReset">
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">分类名称</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" value="{{category.name}}" name="name" placeholder="请输入分类名称" />
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">分类编号</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" value="{{category.category_type}}" type="number" name="category_type" placeholder="请输入分类编号" />
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">排序</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" value="{{category.order}}" type="number" name="order" placeholder="请输入排序" />
</view>
</view>
</view>
<view class="footer">
<button class="btn_login" formType="submit">保存</button>
</view>
</form>
/* miniprogram/pages/admin/editCategory/editCategory.wxss */
\ No newline at end of file
......@@ -5,16 +5,190 @@ Page({
* 页面的初始数据
*/
data: {
files: [],
categories: [],
food:{}
},
// 上传图片
doUpload: function () {
var that = this;
// 选择图片
wx.chooseImage({
count: 1,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
wx.showLoading({
title: '上传中',
})
const filePath = res.tempFilePaths[0];
console.log(filePath)
// 上传图片
const cloudPath = 'product-' + new Date().getTime() + filePath.match(/\.[^.]+?$/)[0]
wx.cloud.uploadFile({
cloudPath,
filePath,
success: res => {
console.log('[上传文件] 成功:', res)
that.files = [res.fileID];
that.setData({
files: [res.fileID]
});
},
fail: e => {
console.error('[上传文件] 失败:', e)
wx.showToast({
icon: 'none',
title: '上传失败',
})
},
complete: () => {
wx.hideLoading()
}
})
},
fail: e => {
console.error(e)
}
})
},
previewImage: function (e) {
// wx.previewImage({
// current: e.currentTarget.id, // 当前显示图片的http链接
// urls: [e.currentTarget.id] // 需要预览的图片http链接列表
// })
this.setData({
show: true,
currentIndex: 0
})
},
change(e) {
console.log('current index has changed', e.detail)
},
deleteImg(e) {
console.log('delete', e.detail.url)
const that = this;
wx.cloud.deleteFile({
fileList: [e.detail.url],
success: res => {
// handle success
console.log(res.fileList)
wx.showToast({
icon: 'none',
title: '删除成功',
})
that.files = that.files.filter(v => v !== e.detail.url);
that.setData({
files: that.files
})
},
fail: err => {
wx.showToast({
icon: 'none',
title: '删除失败',
})
},
complete: res => {
}
})
},
hide() {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var id = options.id;
this.getFood(id);
},
bindCategoryChange(e) {
console.log(e);
var index = e.detail.value;
this.setData({
categoryIndex: index
})
},
getFood(id){
const that = this;
wx.showLoading({
title: 'loading...',
});
wx.cloud.callFunction({
name:'foodList',
data:{
action:'find',
"_id":id
},
success(res){
if(res.result.code == 1){
that.categories = wx.getStorageSync('categories');
that.food = res.result.data;
that.files = [that.food.img];
that.setData({
food: that.food,
categories: that.categories,
categoryIndex: that.categories.findIndex(val => val.category_type == that.food.category_type),
files: that.files
})
}
},
fail(){},
complete(){
wx.hideLoading();
}
})
},
formSubmit(e) {
console.log(e);
const value = e.detail.value;
const that = this;
var params = {
action: 'edit',
name: value.name,
price: value.price,
desc: value.desc,
order: value.order,
category_type: this.categories.find((val, index) => index == value.categoryIndex).category_type,
img: this.files[0],
"_id": this.food._id
}
wx.showLoading({
title: '正在更新...',
})
wx.cloud.callFunction({
name: 'foodList',
data: params,
success(res) {
if (res.result.code == 1) {
wx.showToast({
title: '更新成功',
success() {
wx.navigateBack();
}
})
}
},
fail() {
wx.showToast({
title: '更新失败',
icon: 'fail'
})
},
complete() {
wx.hideLoading();
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
......
{
"usingComponents": {}
"usingComponents": {
"mp-gallery": "../components/gallery/gallery"
}
}
\ No newline at end of file
<!--miniprogram/pages/admin-foodList/editFood/editFood.wxml-->
<text>miniprogram/pages/admin-foodList/editFood/editFood.wxml</text>
<!--miniprogram/pages/admin-foodList/addFood/addFood.wxml-->
<form bindsubmit="formSubmit">
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">食品名称</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" value="{{food.name}}" name="name" placeholder="请输入食品名称" />
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">食品价格</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" type="number" value="{{food.price}}" name="price" placeholder="请输入食品价格" />
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">食品描述</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" value="{{food.desc}}" name="desc" placeholder="请输入食品描述" />
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">排序</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" type="number" value="{{food.order}}" name="order" placeholder="请输入排序" />
</view>
</view>
<view class="weui-cell weui-cell_select">
<view class="weui-cell__hd weui-cell__hd_in-select-after">
<view class="weui-label" style="padding-left:16px;">选择食品分类</view>
</view>
<view class="weui-cell__bd">
<picker bindchange="bindCategoryChange" name="categoryIndex" value="{{categoryIndex}}" range="{{categories}}" range-key="name">
<view class="weui-select weui-select_in-select-after">{{categories[categoryIndex].name}}</view>
</picker>
</view>
</view>
<view class="weui-cells">
<view class="weui-cell">
<view class="weui-cell__bd">
<view class="weui-uploader">
<view class="weui-uploader__hd">
<view class="weui-uploader__overview">
<view class="weui-uploader__title">图片上传</view>
<view class="weui-uploader__info">{{files.length}}/2</view>
</view>
<view class="weui-uploader__tips">
上传提示
</view>
</view>
<view class="weui-uploader__bd">
<view class="weui-uploader__files" id="uploaderFiles">
<block wx:for="{{files}}" wx:key="*this">
<view class="weui-uploader__file" bindtap="previewImage" id="{{item}}">
<image class="weui-uploader__img" src="{{item}}" mode="aspectFill" />
</view>
</block>
</view>
<view class="weui-uploader__input-box">
<view class="weui-uploader__input" bindtap="doUpload"></view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="footer">
<button class="btn_login" formType="submit">保存</button>
</view>
</form>
<mp-gallery show="{{show}}" bindchange="change" binddelete="deleteImg" bindhide="hide" img-urls="{{files}}" delete hide-on-click="{{true}}" current="{{currentIndex}}"></mp-gallery>
\ No newline at end of file
......@@ -7,11 +7,57 @@ Page({
* 页面的初始数据
*/
data: {
foodList:[]
},
slideButtonTap(e) {
console.log('slide button tap', e.detail)
console.log('slide button tap', e)
var id = e.currentTarget.dataset.id;
if (e.detail.index == 0) { // 查看
this.viewFood();
} else if (e.detail.index == 1) { //编辑
this.editFood(id);
}else{
this.delFood(id);
}
},
editFood(id){
wx.navigateTo({
url: '../editFood/editFood?id=' + id,
})
},
delFood(id){
const that = this;
wx.showModal({
title: '确认删除吗',
success() {
wx.cloud.callFunction({
name: 'foodList',
data: {
action: 'del',
"_id": id
},
success(res) {
if (res.result.code == 1) {
wx.showToast({
title: res.result.msg,
success() {
that.getFoodList()
}
})
}
},
fail() {
wx.showToast({
title: '删除失败',
icon: 'fail'
})
}
})
}
})
},
/**
* 生命周期函数--监听页面加载
*/
......@@ -35,6 +81,36 @@ Page({
});
},
getFoodList(){
const that = this;
wx.showLoading({
title: '正在获取...',
});
wx.cloud.callFunction({
name:'foodList',
data:{
action:'findAllList'
},
success(res){
if(res.result.code == 1){
that.foodList = res.result.data;
that.setData({
foodList: res.result.data,
loading:true
})
}
},
fail(){
wx.showToast({
title: '获取失败',
icon:'fail'
})
},
complete(){
wx.hideLoading();
}
})
},
goAdd(){
wx.navigateTo({
url: '../addFood/addFood',
......@@ -49,19 +125,12 @@ Page({
onReady: function () {
},
itemSizeFunc: function (item, idx) {
return {
width: 162,
height: 182
}
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getFoodList();
},
/**
......
<!--miniprogram/pages/admin-foodList/admin-foodList.wxml-->
<view class="page">
<view class="weui-slidecells">
<mp-slideview buttons="{{slideButtons}}" icon="{{true}}" bindbuttontap="slideButtonTap">
<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<image class="weui-media-box__thumb" src="{{icon60}}" />
</view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">标题二</view>
<view class="weui-media-box__desc">由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。</view>
</view>
</navigator>
</mp-slideview>
<block wx:for="{{foodList}}" wx:key="item">
<mp-slideview buttons="{{slideButtons}}" icon="{{true}}" data-id="{{item._id}}" bindbuttontap="slideButtonTap">
<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<image class="weui-media-box__thumb" src="{{item.img}}" />
</view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">{{item.name}}</view>
<view class="weui-media-box__desc">{{item.desc}}</view>
</view>
<view class="weui-media-box__fd">
<text class="text-error">¥{{item.price}}</text>
</view>
</navigator>
</mp-slideview>
</block>
</view>
<block wx:if="{{foodList.length ==0 && loading}}">
<view class="weui-msg">
<view class="weui-msg__icon-area">
<image src="../../../images/svg/noData.svg" style="width:80px;height:80px;"></image>
<!-- <icon type="warn" size="64"></icon> -->
</view>
<view class="weui-msg__text-area">
<view class="weui-msg__title">暂无数据</view>
</view>
</view>
</block>
<view class="footer" bindtap="goAdd">
<text>新增</text>
</view>
</view>
\ No newline at end of file
</view>
......@@ -12,4 +12,8 @@
}
.weui-media-box {
background: #fff;
}
\ No newline at end of file
}
mp-slideview{
margin: 8px 0;
display: block;
}
// miniprogram/pages/admin/shopInfo/shopInfo.js
const app = getApp();
Page({
/**
......@@ -7,7 +8,9 @@ Page({
data: {
region: [],
customItem: '全部',
bannerFiles:[]
bannerFiles:[],
logoFile:null,
shopInfo:{}
},
bindRegionChange: function (e) {
console.log('picker发送选择改变,携带值为', e.detail.value)
......@@ -21,8 +24,11 @@ Page({
onLoad: function (options) {
const shopInfo = wx.getStorageSync('shopInfo');
if (shopInfo){
this.shopInfo = shopInfo;
this.setData({
shopInfo: shopInfo,
logoFile: shopInfo.logo,
bannerFiles: shopInfo.banners,
region: [shopInfo.province, shopInfo.city, shopInfo.district]
})
}
......@@ -50,6 +56,7 @@ Page({
filePath,
success: res => {
console.log('[上传文件] 成功:', res)
that.logoFile = res.fileID;
that.setData({
logoFile: res.fileID
});
......@@ -173,6 +180,84 @@ Page({
hide() {
},
chooseLocation(e){
const result = e.currentTarget.dataset;
const that = this;
console.log(result);
app.chooseLocation({
latitude: result.location.coordinates[1],
longitude: result.location.coordinates[0],
},{
success(res){
Object.assign(that.shopInfo,{
address: res.address + res.name,
location:{
coordinates: [res.longitude, res.latitude]
}
})
console.log(that.shopInfo);
that.setData({
shopInfo: that.shopInfo
});
},
fail(){}
});
},
formSubmit(e){
console.log(e);
var result =e.detail.value;
var logoFile = this.logoFile;
var bannerFiles = this.bannerFiles;
wx.showLoading({
title: '正在更新...',
})
wx.cloud.callFunction({
name:'shop',
data:{
name: result.name,
phone: result.phone,
address: result.address,
location: this.shopInfo.location,
introduction: result.introduction,
banners: bannerFiles,
logo: logoFile,
_id:this.shopInfo._id,
action:'edit'
},
success(res){
console.log(res);
if(res.result.code == 1){
wx.showToast({
title: '更新成功',
success(){
wx.setStorageSync('shopInfo', res.result.data)
wx.navigateBack();
}
})
}else{
wx.showToast({
icon: 'none',
title: '更新失败',
})
}
},
fail(error){
console.log(error);
wx.showToast({
icon: 'none',
title: '更新失败',
})
},
complete: () => {
wx.hideLoading();
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
......
......@@ -22,22 +22,11 @@
<view class="weui-label">店铺地址</view>
</view>
<view class="weui-cell__bd">
<picker mode="region" bindchange="bindRegionChange" value="{{region}}" custom-item="{{customItem}}">
<view class="picker">
{{region[0]}},{{region[1]}},{{region[2]}}
</view>
</picker>
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__hd">
<view class="weui-label">详细地址</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" value="{{shopInfo.address}}" name="address" placeholder="请输入详细地址" />
<textarea bindblur="bindTextAreaBlur" value="{{shopInfo.address}}" name="address" auto-height placeholder="获取地址信息" style="width:100%;min-height:70px;" />
</view>
<view class="weui-cell_fd">
<button type="primary" size="mini" bindtap="chooseLocation" data-location="{{shopInfo.location}}" >获取经纬度</button>
<button type="primary" size="mini" bindtap="chooseLocation" data-location="{{shopInfo.location}}">定位</button>
</view>
</view>
<view class="weui-cell ">
......@@ -61,9 +50,9 @@
</view>
<view class="weui-uploader__bd">
<view class="weui-uploader__files" id="uploaderLogoFiles">
<view class="weui-uploader__file" wx:if="{{logoFile}}" bindtap="previewLogoImage" id="{{logoFile}}">
<image class="weui-uploader__img" src="{{logoFile}}" mode="aspectFill" />
</view>
<view class="weui-uploader__file" wx:if="{{logoFile}}" bindtap="previewLogoImage" id="{{logoFile}}">
<image class="weui-uploader__img" src="{{logoFile}}" mode="aspectFill" />
</view>
</view>
<view class="weui-uploader__input-box">
<view class="weui-uploader__input" bindtap="doLogoUpload"></view>
......
......@@ -5,7 +5,17 @@ Page({
* 页面的初始数据
*/
data: {
order:null,
getFoodTimeList:[
{name:'现在取餐',value:0,checked:true},
{ name: '10分钟后到店', value: 10 },
{ name: '20分钟后到店', value: 20},
{ name: '30分钟后到店', value: 30 },
],
getFoodWayList:[
{ name: '堂食', value: 1, checked: true },
{ name: '外带', value: 2 },
]
},
onPay(){
......@@ -21,9 +31,34 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
const cart = wx.getStorageSync('cart');
const shopInfo = wx.getStorageSync('shopInfo');
this.order = {
foodList: cart.foodList,
order_total_price: cart.cart_price,
}
this.setData({
shopInfo,
order: this.order,
total_count: cart.cart_count
})
},
formSubmit(e){
console.log(e);
var value =e.detail.value;
if (!value.phone){
wx.showToast({
title: '请填写订餐电话',
icon:'warn'
})
return;
}
var params = {
...this.order,
...value
}
console.log(params);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
......
<!--miniprogram/pages/confirm-order/confirm-order.wxml-->
<import src="/template/stepper.wxml" />
<view class="page">
<!-- 订单菜品信息 -->
<view class="weui-panel weui-panel_access">
<view class="weui-panel__hd">xxxx店铺</view>
<view class="weui-panel__bd">
<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<image class="weui-media-box__thumb" src="/images/banner-1.jpg" />
</view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">菜品xxxx</view>
<view class="weui-media-box__desc">主要原料:xxxxx</view>
<view class="info weui-flex">
<text class="price">¥25.00</text>
<template is="stepper"></template>
</view>
</view>
</navigator>
<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<image class="weui-media-box__thumb" src="/images/banner-1.jpg" />
</view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">菜品xxxx</view>
<view class="weui-media-box__desc">主要原料:xxxxx</view>
</view>
</navigator>
</view>
<view class="weui-panel__ft">
<view class="weui-cell weui-cell_access weui-cell_link">
<view class="weui-cell__bd"></view>
<view class="weui-cell__ft">
共1道菜品 合计
<text class="text-error">¥28.00</text>
</view>
</view>
</view>
</view>
<!-- 取餐时间 -->
<view class="weui-panel" style="padding:16px;">
<view class="title" style="margin-bottom:8px;">请选择取餐时间</view>
<view class="get-order-time-list">
<radio-group class="radio-group" bindchange="radioChange">
<view class="weui-flex">
<view class="weui-flex__item">
<view class="placeholder">
<radio class="radio weui-flex__item">
<text>现在取餐</text>
</radio>
<form bindsubmit="formSubmit">
<view class="page">
<!-- 订单菜品信息 -->
<view class="weui-panel weui-panel_access">
<view class="weui-panel__hd">{{shopInfo.name}}</view>
<view class="weui-panel__bd">
<block wx:for="{{order.foodList}}" wx:key="item">
<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<image class="weui-media-box__thumb" src="{{item.img}}" />
</view>
</view>
<view class="weui-flex__item">
<view class="placeholder">
<radio class="radio weui-flex__item">
<text>10分钟后到店</text>
</radio>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">{{item.name}}</view>
<view class="weui-media-box__desc">主要原料:{{item.desc}}</view>
<view class="info weui-flex">
<text class="price">¥{{item.out_count*item.price}}</text>
<text>×{{item.out_count}}</text>
</view>
</view>
</navigator>
</block>
</view>
<view class="weui-panel__ft">
<view class="weui-cell weui-cell_access weui-cell_link">
<view class="weui-cell__bd"></view>
<view class="weui-cell__ft">
共{{total_count}}道菜品 合计
<text class="text-error">¥{{order.order_total_price}}</text>
</view>
</view>
<view class="weui-flex">
<view class="weui-flex__item">
<view class="placeholder">
<radio class="radio weui-flex__item">
<text>20分钟后到店</text>
</radio>
</view>
</view>
<!-- 取餐时间 -->
<view class="weui-panel" style="padding:16px;">
<view class="title" style="margin-bottom:8px;">请选择取餐时间</view>
<view class="get-order-time-list">
<radio-group class="radio-group" bindchange="radioChange" name="take_food_time">
<view class="weui-flex" wx:for-items="{{getFoodTimeList}}" wx:key="name">
<view class="weui-flex__item">
<view class="placeholder">
<radio class="radio weui-flex__item" value="{{item.value}}" checked="{{item.checked}}">
<text>{{item.name}}</text>
</radio>
</view>
</view>
</view>
<view class="weui-flex__item">
<view class="placeholder">
<radio class="radio weui-flex__item">
<text>30分钟后到店</text>
</radio>
</view>
</radio-group>
</view>
</view>
<!-- 预留取餐电话 -->
<view class="weui-panel padding-md">
<input class="weui-input" placeholder="请填写您的电话" name="phone" />
</view>
<!-- 堂食还是外带 -->
<view class="weui-panel padding-md">
<radio-group class="radio-group weui-flex" bindchange="radioChange" name="take_food_way">
<view class="weui-flex__item" wx:for-items="{{getFoodWayList}}" wx:key="name">
<view class="placeholder text-center">
<radio class="radio" value="{{item.value}}" checked="{{item.checked}}">
{{item.name}}
</radio>
</view>
</view>
</radio-group>
</view>
</view>
<!-- 预留取餐电话 -->
<view class="weui-panel padding-md">
<input class="weui-input" placeholder="请填写您的电话" />
</view>
<!-- 堂食还是外带 -->
<view class="weui-panel padding-md">
<radio-group class="radio-group weui-flex" bindchange="radioChange">
<view class="weui-flex__item">
<view class="placeholder text-center">
<radio class="radio">
堂食
</radio>
</view>
</view>
<view class="weui-flex__item">
<view class="placeholder text-center">
<radio class="radio">
外带
</radio>
</view>
<!-- 订单备注 -->
<view class="remark weui-panel padding-md">
<input class="weui-input" placeholder="订单备注,请告诉我们您还有什么要求" name="remark" />
</view>
<!-- 支付方式 -->
<view class="payment text-center">
<text>支付方式: 微信支付</text>
</view>
<view class="tips">
<text>支付成功我们才能收到您的订单!</text>
</view>
<!-- 提交订单 -->
<view class="sub-wrap weui-flex">
<text>合计:¥{{order.order_total_price}}</text>
<view class="pay-btn">
<button form-type="submit" type="warn">去支付</button>
</view>
</radio-group>
</view>
<!-- 订单备注 -->
<view class="remark weui-panel padding-md">
<input class="weui-input" auto-focus placeholder="订单备注,请告诉我们您还有什么要求" />
</view>
<!-- 支付方式 -->
<view class="payment text-center">
<text>支付方式: 微信支付</text>
</view>
<view class="tips">
<text>支付成功我们才能收到您的订单!</text>
</view>
<!-- 提交订单 -->
<view class="sub-wrap weui-flex">
<text>合计:¥28.00</text>
<view class="pay-btn">
<button type="warn" bindtap="onPay">去支付</button>
</view>
</view>
</view>
\ No newline at end of file
</form>
\ No newline at end of file
......@@ -2,7 +2,7 @@
<view class="container">
<view class="banner-wrapper" style="width:100%;">
<swiper autoplay="true">
<block wx:for="{{bannerList}}" wx:key="*this">
<block wx:for="{{shopInfo.banners}}" wx:key="*this">
<swiper-item>
<image src="{{item}}" class="banner-img" mode="aspectFill"></image>
</swiper-item>
......
......@@ -5,58 +5,309 @@ Page({
* 页面的初始数据
*/
data: {
showDialog: false
showDialog: false,
cart:null, // 购物车信息
foodList:[],
food:{}
},
goOrder(){
wx.setStorageSync('cart', this.cart);
wx.navigateTo({
url: '../confirm-order/confirm-order',
})
},
getDetail(){
console.log('中间');
},
addOne(){
console.log('添加一份');
},
getCategories(){
addCart(e){
const that =this;
var foodId = e.currentTarget.dataset.foodId;
wx.cloud.callFunction({
name:'cart',
data:{
action:'addCart',
foodId,
out_count:1,
},
success(res){
if(res.result.code == 1){
that.foodList.map(val => {
if(val._id == foodId){
val.out_count = 1
}
});
if(that.food) that.food.out_count = 1;
that.setData({
foodList: that.foodList,
food:that.food
})
that.getCart();
}
}
})
},
getCart(){
const that = this;
wx.cloud.callFunction({
name:'categories',
data:{},
success:(res)=>{
// 默认加载第一个分类的数据
const categories = res.result.categories.data;
wx.cloud.callFunction({
name:'foodList',
data:{
category_type: categories[0].category_type
},
success:(food)=>{
name:'cart',
data: { action:'findAll'},
success(res){
console.log(res);
if(res.result.code == 1){
var carts = res.result.data;
that.cart = carts[0] || null;
// 遍历购物车中foodlist 同时遍历获取foodlist
// 如果两个id相同,更新foodlist out_count值
if (carts.length !==0){
that.cart.foodList.forEach(function (cFood) {
that.foodList.forEach(function (food) {
if (cFood._id == food._id) {
food.out_count = cFood.out_count;
}
})
})
}
that.setData({
foodList: that.foodList,
cart: that.cart
})
console.log(that.foodList);
that.setData({
categories: categories,
tabSelected: categories[0]._id,
foodList: food.result.foodList.data
})
},
fail:()=>console.error('获取食品失败')
})
}
}
})
},
/**
* 获取分类信息 加载第一分类下的食品信息
*/
getCategories(){
const that = this;
const categories = wx.getStorageSync('categories');
if (categories){
that.getFood(categories[0].category_type, {
success(res) {
that.foodList = res.result.data;
that.setData({
categories: categories,
foodList: res.result.data,
tabSelected: categories[0]._id,
})
that.getCart(res.result.data);
}
});
}else{
wx.cloud.callFunction({
name: 'categories',
data: { action:'find'},
success: (res) => {
if(res.result.code == 1){
// 默认加载第一个分类的数据
const categories = res.result.data;
wx.setStorageSync('categories', categories);
that.getFood(categories[0].category_type, {
success(res) {
that.foodList = res.result.data;
that.setData({
categories: categories,
foodList: res.result.data,
tabSelected: categories[0]._id,
})
that.getCart(res.result.data);
}
});
}
},
fail: () => {
console.error('获取分类失败');
}
})
}
},
handleZanStepperMinus(e){
console.log(e);
var foodId = e.currentTarget.dataset.foodId;
var stepper = e.currentTarget.dataset.stepper-1;
if (stepper == 0) {
this.delCart(foodId);
} else {
this.updateCart(foodId, stepper);
}
},
handleZanStepperPlus(e){
console.log(e);
var foodId = e.currentTarget.dataset.foodId;
var stepper = e.currentTarget.dataset.stepper+1;
this.updateCart(foodId,stepper);
},
delCart(foodId){
const that = this;
wx.cloud.callFunction({
name:'cart',
data:{
action:'deleteCartOne',
cartId: that.cart._id,
foodId,
},
fail:()=>{
console.error('获取分类失败');
success(res){
if(res.result.code == 1){
that.foodList.map(val => {
if (val._id == foodId) {
val.out_count = 0
}
});
if(that.food) that.food.out_count = 0;
that.setData({
foodList: that.foodList,
food: that.food
})
that.getCart();
}
}
})
},
openDialog: function () {
this.setData({
istrue: true
/**
* 更新购物车信息
*/
updateCart(foodId, stepper){
const that = this;
wx.cloud.callFunction({
name:'cart',
data:{
action: 'updateCart',
cartId: that.cart._id,
foodId,
out_count: stepper
},
success(res){
if(res.result.code == 1){
that.foodList.map(val => {
if (val._id == foodId) {
val.out_count = stepper
}
});
if (that.food) that.food.out_count = stepper;
that.setData({
foodList: that.foodList,
food:that.food
})
that.getCart();
}
}
})
},
/**
* 根据category_type获取商品信息
*/
getFood(category_type,callback={}){
const that = this;
wx.cloud.callFunction({
name: 'foodList',
data: {
category_type: category_type,
action:'findListByCategoryType'
},
success: (res) => {
if(res.result.code == 1){
if (typeof callback.success == 'function') callback.success(res);
}
},
fail: () => console.error('获取食品失败')
})
},
/**
* 分类绑定点击事件
*/
changeCategory(e){
const that = this;
var category_type = e.currentTarget.dataset.categoryType;
var category_id = e.currentTarget.dataset.categoryId;
console.log(category_type);
this.getFood(category_type,{
success(res){
that.foodList = res.result.data;
that.setData({
foodList: res.result.data,
tabSelected: category_id,
})
that.getCart(res.result.data);
}
});
},
openDialog: function (e) {
const that = this;
var foodId = e.currentTarget.dataset.foodId;
wx.cloud.callFunction({
name:'foodList',
data:{
action:'find',
_id: foodId
},
success(res){
if(res.result.code == 1){
that.food = res.result.data;
that.foodList.forEach(val=>{
if (val._id == that.food._id){
that.food.out_count = val.out_count;
}
})
console.log(that.food);
that.setData({
food: that.food,
istrue: true
})
}
},
fail(){console.log('获取失败')}
})
},
closeDialog: function () {
this.food = null;
this.setData({
istrue: false
})
},
openCart(){
if(this.cart == null){
wx.showToast({
title: '请选择商品',
icon:''
})
return;
}
this.setData({
showCartBox: true
})
},
closeCartBox(){
this.setData({
showCartBox: false
})
},
deleteAllCart(){
const that = this;
wx.cloud.callFunction({
name:'cart',
data: { action:'deleteAllCart',cartId:this.cart._id},
success(res){
if(res.result.code == 1){
that.foodList.map(val=>val.out_count =0);
that.setData({
foodList:that.foodList,
cart:null,
showCartBox: false
})
that.getCart()
}
},
fail(){console.error("删除失败")}
})
},
/**
* 生命周期函数--监听页面加载
*/
......
......@@ -5,7 +5,7 @@
<view class="category-wrap">
<scroll-view scroll-y="true" style="height: 300rpx;" bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" scroll-into-view="{{toView}}" scroll-top="{{scrollTop}}">
<block wx:for="{{categories}}" wx:key="item">
<view class="cate-item {{tabSelected == item._id?'active':''}}">{{item.name}}</view>
<view class="cate-item {{tabSelected == item._id?'active':''}}" data-category-id="{{item._id}}" data-category-type="{{item.category_type}}" bindtap="changeCategory">{{item.name}}</view>
</block>
</scroll-view>
......@@ -13,19 +13,19 @@
<view class="product-wrap">
<scroll-view scroll-y="true" style="height: 100vh;" bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" scroll-into-view="{{toView}}" scroll-top="{{scrollTop}}">
<block wx:for="{{foodList}}" wx:key="item">
<view class="product-item" bindtap="openDialog">
<view class="product-item" bindtap="openDialog" data-food-id="{{item._id}}">
<view class="p-img">
<image src="/images/banner-1.jpg"></image>
<image src="{{item.img}}"></image>
</view>
<view class="product-detail">
<view class="name">{{item.food_name}}</view>
<view class="price">{{item.food_price}}元</view>
<view class="btn-box" catchtap="getDetail" hover-stop-propagation='true'>
<block wx:if="{{item.out_count == 0}}">
<button type="warn" size="mini" bindtap="addOne" class="add-one"> 点一份 </button>
<view class="name">{{item.name}}</view>
<view class="price">{{item.price}}元</view>
<view class="btn-box">
<block wx:if="{{item.out_count&&item.out_count !== 0}}">
<template is="stepper" data="{{foodId:item._id, stepper:item.out_count,min:0}}"></template>
</block>
<block wx:else>
<template is="stepper"></template>
<button type="warn" size="mini" catchtap="addCart" data-food-id="{{item._id}}" class="add-one" hover-stop-propagation='true'> 点一份 </button>
</block>
</view>
</view>
......@@ -38,16 +38,23 @@
<!-- 购物车 -->
<view class="cart-wrap">
<view class="cart-num">
<view class="cart-num" bindtap="openCart">
<image src="/images/svg/cart.svg" class="icon"></image>
<view class="num">20</view>
<view class="num">{{cart.cart_count||0}}</view>
</view>
<view class="cart-total-price">
<block wx:if="{{cart.cart_price}}">
¥{{cart.cart_price}}
</block>
<block wx:else>
<text>购物车为空</text>
</block>
</view>
<view class="cart-total-price">¥366.00</view>
<view class="search-wrap">
<image src="/images/svg/icon_seach.svg" class="search-icon"></image>
</view>
<view class="btn">
<button type="primary" bindtap="goOrder"> 点好了 </button>
<button type="{{cart == null?'default':'primary'}}" bindtap="goOrder" disabled="{{cart == null}}"> 点好了 </button>
</view>
</view>
</view>
......@@ -59,19 +66,72 @@
<view class="weui-dialog" catchtap="stopEvent">
<view class="weui-dialog__hd">
<view class="weui-dialog__title">
xxx菜品
{{food.name}}
<image src="/images/svg/close.svg" class="icon close" bindtap="closeDialog"></image>
</view>
</view>
<view class="weui-dialog__bd">
<image class="weui-article__img" src="/images/banner-1.jpg" mode="aspectFill" style="max-width:100%;" />
<image class="weui-article__img" src="{{food.img}}" mode="aspectFill" style="max-width:100%;" />
</view>
<view class="weui-dialog__ft">
<text class="price">¥9.6</text>
<view style="margin-right:16px;">
<button type="warn" class="add-cart">加入购物车</button>
<text class="price">¥{{food.price}}</text>
<view style="margin-right:16px;" class="weui-flex">
<block wx:if="{{food.out_count&&food.out_count !== 0}}">
<template is="stepper" data="{{foodId:food._id, stepper:food.out_count,min:0}}"></template>
</block>
<block wx:else>
<button type="warn" size="mini" catchtap="addCart" data-food-id="{{food._id}}" class="add-one" hover-stop-propagation='true'> 点一份 </button>
</block>
</view>
</view>
</view>
</view>
</view>
<view class="weui-demo-dialog {{showCartBox ? 'weui-demo-dialog_show' : ''}}">
<view class="weui-mask" bindtap="closeCartBox"></view>
<view class="weui-half-screen-dialog">
<view class="weui-half-screen-dialog__hd">
<view class="weui-half-screen-dialog__hd__side">
<view bindtap="closeCartBox" class="weui-icon-btn weui-icon-btn_close">关闭</view>
</view>
<view class="weui-half-screen-dialog__hd__main">
<text class="weui-half-screen-dialog__title">已选商品</text>
</view>
<view class="weui-half-screen-dialog__hd__side">
<view class="clear-btn" bindtap="deleteAllCart">
<image src="../../images/svg/delete.svg" class="icon clear-icon"></image>
<text>清空购物车</text>
</view>
</view>
</view>
<view class="weui-half-screen-dialog__bd">
<view class="product-wrap" style="margin-left:0;">
<scroll-view scroll-y="true" style="max-height: '70%';" bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" scroll-into-view="{{toView}}" scroll-top="{{scrollTop}}">
<block wx:for="{{cart.foodList}}" wx:key="item">
<view class="product-item" bindtap="openDialog" data-food-id="{{item._id}}">
<view class="p-img">
<image src="{{item.img}}"></image>
</view>
<view class="product-detail">
<view class="name">{{item.name}}</view>
<view class="price">{{item.price}}元</view>
<view class="btn-box">
<block wx:if="{{item.out_count&&item.out_count !== 0}}">
<template is="stepper" data="{{foodId:item._id, stepper:item.out_count,min:0}}"></template>
</block>
<block wx:else>
<button type="warn" size="mini" catchtap="addCart" data-food-id="{{item._id}}" class="add-one" hover-stop-propagation='true'> 点一份 </button>
</block>
</view>
</view>
</view>
</block>
</scroll-view>
</view>
</view>
<view class="weui-half-screen-dialog__ft">
</view>
</view>
</view>
\ No newline at end of file
......@@ -3,7 +3,7 @@
position: fixed;
width: 100%;
bottom: 0;
z-index: 6000;
z-index: 12000;
display: flex;
align-items: center;
border-top: 1px solid #eee;
......@@ -41,7 +41,7 @@ font-size: 12px;
width: 24px;
height: 24px;
}
.cart-wrap .btn button{
.cart-wrap .btn button[type=primary]{
width:120px;
margin-right: 10px;
background: red !important;
......@@ -86,7 +86,7 @@ font-size: 12px;
justify-content: space-between;
align-items: center;
}
.product-wrap .product-item .product-detail .add-one{
.add-one{
width: 100px;
height: 30px !important;
border-radius: 30px;
......@@ -136,4 +136,14 @@ font-size: 12px;
.weui-dialog__ft {
justify-content: space-between;
align-items: center;
}
.weui-half-screen-dialog__hd__side+.weui-half-screen-dialog__hd__main{
text-align: left;
}
.clear-icon{
width:18px;
height:18px;
}
.clear-btn text{
font-size: 12px;
}
\ No newline at end of file
<template name="stepper">
<view class="interval-box">
<image src="/images/svg/minus.svg" data-category-id="{{categoryId}}" data-product-id="{{productId}}" data-component-id="{{ componentId }}" data-stepper="{{ stepper }}" data-disabled="{{ stepper <= min }}" bindtap="_handleZanStepperMinus" class=""></image>
<view class="interval-box">
<image src="/images/svg/minus.svg" data-food-id="{{foodId}}" data-stepper="{{ stepper }}" data-disabled="{{ stepper <= min }}" catchtap="handleZanStepperMinus" class="" hover-stop-propagation='true'></image>
<text class="num" data-component-id="{{ componentId }}" data-min="{{ min }}" data-max="{{ max }}" disabled="{{ min >= max }}"> {{ stepper }}</text>
<image src="/images/svg/plus.svg" data-category-id="{{categoryId}}" data-product-id="{{productId}}" data-component-id="{{ componentId }}" data-stepper="{{ stepper }}" data-disabled="{{ stepper >= max }}" bindtap="_handleZanStepperPlus"></image>
<text class="num" data-min="{{ min }}" data-max="{{ max }}" disabled="{{ min >= max }}"> {{ stepper }}</text>
<image src="/images/svg/plus.svg" data-food-id="{{foodId}}" data-stepper="{{ stepper }}" data-disabled="{{ stepper >= max }}" catchtap="handleZanStepperPlus" hover-stop-propagation='true'></image>
</view>
</template>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment