Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a6145c6
update ignore
Jun 3, 2019
cf82a23
添加了自动生成的models, service/api, 修改了address Edit -> addressUpdate ,让页面平级
Jun 4, 2019
32e4aa5
open ql log, fix path ref bug
Jun 4, 2019
dfd2129
add dva, home is work under h5
Jun 4, 2019
366ffbb
clean no use code
Jun 4, 2019
15b8887
prepare add new collection
Jun 4, 2019
1470e1e
dva in detail not work
Jun 4, 2019
9605a1e
recommand list 和 product list分开,避免相互影响
Jun 4, 2019
9751536
修改api 返回参数
Jun 4, 2019
dcc5785
fix specificationStockList not work bug
Jun 4, 2019
0610616
add more import of models
Jun 4, 2019
a989594
cart work, 暂时写回state
Jun 4, 2019
57510c2
address query
Jun 4, 2019
35d595e
change order list to dva
Jun 4, 2019
226d681
another orderList use dva
Jun 4, 2019
0284e55
替换findMany in orders
Jun 4, 2019
cab885d
change to mock
Jun 4, 2019
af6725e
move QL.init to app.js
Jun 4, 2019
7a8c53e
change delete and create to dva
Jun 4, 2019
1ba130d
mutate 替换为dva
Jun 5, 2019
1f1c708
修改 global -> dva common, 其他补漏
Jun 5, 2019
d5883a0
还原之前的修改 (spec)
Jun 5, 2019
56d9bf0
同步cloud分支的修改,解决id undefined 问题
Jun 5, 2019
3046926
change complex user query
Jun 5, 2019
80b790a
change: nervjs 1.3.12 to support this.setState ok
Csy817 Jun 5, 2019
95d7645
fetch cartList after insert and delete cart
Csy817 Jun 5, 2019
f078f59
分离了specification 和 stock
Jun 5, 2019
80d09b1
Merge remote-tracking branch 'origin/dva' into dva
Jun 5, 2019
c54ea96
把delete的增强模式(where) 先改成普通模式,mock 目前用的fc-db,还没支持where
Jun 5, 2019
2e08ffa
detail数据传入
Jun 5, 2019
9459c11
去掉一部分payrecord数据,以便形成key
Jun 6, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ node_modules/
/temp
/data
/schema
package-lock.json
package-lock.json
mock/data
mock/schema
mock/temp
9 changes: 8 additions & 1 deletion client/config/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@ module.exports = {
defineConstants: {
},
weapp: {},
h5: {}
h5: {
devServer: {
host: 'localhost', // 如需局域网(如手机)访问,请更换为0.0.0.0
// host: '0.0.0.0', // 如需局域网(如手机)访问,请更换为0.0.0.0
port: 8088,
https: false
}
}
}
67 changes: 67 additions & 0 deletions client/draft/address.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import {getGlobalData} from "../src/utils/global_data";
import {findMany, insert, remove, update} from "../src/utils/crud";
import Taro from "@tarojs/taro";

getAddressData = () => {
let user_id = getGlobalData("user_id")
let fields = ["address", "telephone", "default", "city", "username", "id", "area", "province"]
findMany({collection:"userAddress",condition:{user_id: user_id},fields}).then(res =>{
// console.log('address userAddressData',res)
this.setState({
loaded: true,
shoppingAddress: res
});
})
}


// 获取用户收货地址,缓存无则重新获取
getUserAddressData = () => {
let selectAddress = Taro.getStorageSync('ordersAddress')
if(selectAddress){
this.setState({
selectAddress
})
}else {
let user_id = getGlobalData("user_id")
let fields = ["id", "default", "username", "telephone", "province", "area", "city", "address"]
findMany({collection:"userAddress",condition:{user_id: user_id,default:1},fields}).then(res =>{
// console.log('orders userAddressData',res)
this.setState({
selectAddress: res[0]
})
Taro.setStorage({ key: 'ordersAddress', data: res[0] })
})
}
}

insert({collection:'userAddress',condition: addressContent}).then((res)=>{
if(res.result === "ok"){
this.message('地址创建成功')
Taro.setStorageSync('ordersAddress', addressContent)
this.goBackPage(1)
}else{
this.message('地址创建失败,请重新创建')
}
})

update({collection: 'userAddress',condition: addressContent}).then((res)=>{
if(res.result === "ok"){
this.message('地址更新成功')
Taro.setStorageSync('ordersAddress', addressContent)
this.goBackPage(1)
}else{
this.message('地址更新失败,请重新创建')
}
})

remove({collection:"userAddress",condition:{id:deleteId}}).then((data)=>{
// console.log('delete userAddress data',data)
if(data === "ok"){
Taro.showToast({
title: '删除成功',
icon: 'none'
})
this.getAddressData()
}
})
30 changes: 30 additions & 0 deletions client/draft/cart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 获取购物车数据
import {getGlobalData} from "../src/utils/global_data";
import {findMany} from "../src/utils/crud";
import Taro from "@tarojs/taro";

getCartData = () => {
let user_id = getGlobalData("user_id")
const fields = [
"count",
"id",
"product_id{id, img, intro, name, price, status, stock, unit, discountRate}",
"specificationStock_id{id, color, size, stock, status}"
]
findMany({collection:"userCart",condition:{user_id},fields}).then((res)=>{
// console.log(`cartList`,res)
res.forEach((item)=>{
item.checked = false
})
this.setState({
loaded:true,
cartList:res
},()=>{
if(res.length){
this.sumPrice(true)
}else {
Taro.setStorage({key: 'cartCount', data: 0})
}
})
})
}
20 changes: 20 additions & 0 deletions client/draft/detail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {findMany, findOne} from "../src/utils/crud";
import Taro from "@tarojs/taro";

let detail = findOne({collection:"product",condition:{id: productId},fields:["name", "id", "intro", "price", "img", "stock", "discountRate", "status"]})
let detailSpec = findMany({collection:"specificationStock",condition:{product_id: productId},fields:["id", "color", "size", "slideImg", "detailImg", "stock", "status"]})

Promise.all([detail, detailSpec]).then((res)=>{
// console.log('detail spec data',res)
this.setState({
loaded:true,
detailInfo: res[0],
detailSpec: res[1]
});
})

// let user_id = getGlobalData("user_id")
// findMany({collection:"userCart",condition:{user_id},fields:["id","count"]}).then((res)=>{
// console.log(`cartList count`,res)


16 changes: 16 additions & 0 deletions client/draft/footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {remove} from "../src/utils/crud";
import Taro from "@tarojs/taro";

cancelOrder = (id) => {
let deleteOrder = remove({collection: "order",condition: {id}})
let deleteOrderProduct = remove({collection: "orderProduct",condition:{order_id:id}})
Promise.all([deleteOrder, deleteOrderProduct]).then((res)=>{
// console.log('delete order res',res)
if(res[0] === "ok" && res[1] === "ok"){
Taro.showToast({
title: '删除成功',
icon: 'none'
})
}
})
}
48 changes: 48 additions & 0 deletions client/draft/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {findMany} from "../src/utils/crud";

getSlideShow = () => {
findMany({collection:"slideshow",fields:["id","img"]}).then((res)=>{
// console.log("getSlideShow res",res)
let swiperList = []
res.forEach((item,index)=>{
swiperList.push(item.img)
if(index === res.length -1){
this.setState({
swiperList
})
}
})
})
}

getGoodsInfo = () => {
const categoryFilter = {
"status": "1",
"limit": 7,
// "sort_by": {"order": "asc"}
}

let category = findMany({collection: "category",condition:categoryFilter,fields:["id", "value:name", "image:img", "status"]})
let recommend = findMany({collection:"product",condition: {status: '1', recommend: 1},fields:["name", "id", "intro", "price", "img", "stock", "discountRate", "status"]})

Promise.all([category, recommend]).then((res)=>{
// console.log('getGoodsInfo data',res)
this.setState({
loaded:true,
category: res[0],
recommend: res[1]
})
})

// QL.find([["category",categoryFilter, ["id", "value:name", "image:img", "status"]],
// ["product",{status: '1', recommend: 1}, ["name", "id", "intro", "price", "img", "stock", "discountRate", "status"]]]).then(
// res=>{
// console.log('fetch data',res);
// this.setState({
// loaded:true,
// category: res[0],
// recommend: res[1]
// });
// }
// )
}
14 changes: 14 additions & 0 deletions client/draft/kind.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {findMany} from "../src/utils/crud";
import Loading from "../src/components/loading";

findMany({collection:"product",condition:{category_id: this.categoryId},fields:["category_id.name", "name", "id", "intro", "price", "img", "stock", "discountRate", "status"]}).then((res)=>{
// console.log("Kind res",res)
this.setState({
loaded:true,
detailInfo:res,
})
})

if (!this.state.loaded) {
return <Loading />
}
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions client/draft/orderList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {findMany} from "../src/utils/crud";

getOrderProductData = () => {
let {orderId} = this.props
// console.log("getOrderProductData orderId",orderId)
const fields = [
"productColor", "unit", "productSize","orderPay", "productImg", "productName", "productPrice", "id", "count", "productPay",
"product_id{id, unit, img, intro, name, price, status, stock, unit, discountRate}"
]
findMany({collection:'orderProduct',condition:{order_id:orderId},fields}).then((res) => {
// console.log("getOrderProductData res",res)
this.setState({
product: res
})
})
}


getOrderData = () => {
let {orderStatus} = this.state
let {user_id} = this.props
// console.log("getOrderData orderStatus",orderStatus,"user_id",user_id)

let fields = ["orderTotalPay", "createdAt", "orderStatus", "id", "count", "productTotalPay", "user_id.id"]
findMany({collection:'order',condition:{user_id, orderStatus},fields}).then((res) => {
// console.log("getOrderData res",res)
this.setState({
loaded:true,
list: res
})
})
}

getOrderByStatus = (orderStatus) => {
// console.log("OrderList orderStatus",orderStatus,typeof orderStatus)

this.setState({
orderStatus
},()=>{
this.getOrderData()
})
}
34 changes: 34 additions & 0 deletions client/draft/orders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {insert, remove} from "../src/utils/crud";
import {setGlobalData} from "../src/utils/global_data";
import Taro from "@tarojs/taro";

let createOrder = insert({collection:'order',condition:orderContent})
let createOrderLogistics = insert({collection:'orderLogistics',condition:orderLogistics})
let deleteUserCart = remove({collection:"userCart",condition:{where:{id: {_in: deleteIdList}}}})
return insert({collection:'orderProduct',condition:orderProduct}).then((data)=>{
// console.log('create orderProduct data',data)
return data
})

Promise.all([createOrder, createOrderLogistics, deleteUserCart, createOrderProduct]).then((data)=> {
// console.log('onSubmitOrderAndProduct data',data)
if(data[0].result === "ok") {
setGlobalData('payOrder',orderContent)
this.changeOrdersState('createOrderStatus', false)
Taro.navigateTo({
url: `/pages/pay/index`
})
if(dataType === 'cartSelected'){
let cartCount = parseInt(Taro.getStorageSync('cartCount')) - totalCount
Taro.setStorageSync('cartCount',cartCount)
Taro.removeStorageSync('cartList')
}
}
}).catch((err)=>{
this.changeOrdersState('createOrderStatus', false)
console.log('submit order error',err)
Taro.showToast({
title:'订单创建失败,请稍后重试',
icon: 'none'
})
})
15 changes: 15 additions & 0 deletions client/draft/pay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {update} from "../src/utils/crud";
import Taro from "@tarojs/taro";

let updateOrderStatus = update({collection:"order",condition:updateContent})
updateOrderStatus.then((data)=>{
// console.log("update order data",data)
if(data.result === "ok"){
$this.message('支付成功,等待发货')
Taro.navigateTo({
url: `/pages/order/index?type=1`
})
}else {
$this.message('支付成功,订单创建失败,请联系商家')
}
})
18 changes: 18 additions & 0 deletions client/draft/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Taro from "@tarojs/taro";
import {insert} from "../src/utils/crud";

let preCartCount = parseInt(Taro.getStorageSync('cartCount')) || 0
let cartCount = preCartCount + count

// 购物车数量显示更新
this.props.onChangeDetailState('cartCount',cartCount)
Taro.showToast({
title: '成功添加至购物车',
icon: 'none'
})
Taro.setStorageSync('cartCount',cartCount)

insert({collection:'userCart',condition:cartContent}).then(()=>{
// console.log('create_userCart data',data)

})
11 changes: 11 additions & 0 deletions client/draft/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {findOne} from "../src/utils/crud";

userInfo = (user_id) => {
let userData = findOne({collection:"user",condition:{id: user_id},fields:["id", "email", "telephone", "username", "openid"]});//,fields:[]
userData.then(res =>{
// console.log('user data',res)
this.setState({
loaded:true,
});
})
}
40 changes: 39 additions & 1 deletion client/mock/ecommerce.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
{:category
{:userCart
[{:id "cart_1557718717372_07617742",
:user_id "ioobot",
:product_id "1",
:specificationStock_id "3",
:count 1,
:createdAt "2019-05-13 11:38:37",
:updatedAt ""
}
{:id "cart_1557718728636_91401876",
:user_id "ioobot",
:product_id "2",
:specificationStock_id "4",
:count 1,
:createdAt "2019-05-13 11:38:48",
:updatedAt ""}]
:slideshow
[{:id "1",
:name "1",
:img
"https://fz-1254337200.cos.ap-chengdu.myqcloud.com/lbt/slide1.jpg",
:status "1",
:createdAt "2019-03-11 12:45:01",
:updatedAt ""}
{:id "2",
:name "2",
:img
"https://fz-1254337200.cos.ap-chengdu.myqcloud.com/lbt/slide2.jpg",
:status "1",
:createdAt "2019-03-11 12:45:01",
:updatedAt ""}
{:id "3",
:name "3",
:img
"https://fz-1254337200.cos.ap-chengdu.myqcloud.com/lbt/slide3.jpg",
:status "1",
:createdAt "2019-03-11 12:45:01",
:updatedAt ""}]
:category
[{:id "jacket",
:name "夹克",
:img
Expand Down
Loading