Kaynağa Gözat

限制了全局样式作用范围

wly 7 yıl önce
ebeveyn
işleme
6bf57ff939

+ 1 - 1
src/case/ShopApp/src/App.css

@@ -17,7 +17,7 @@
     
 }
 
-*::-webkit-scrollbar {display:none !important}
+/*::-webkit-scrollbar {display:none !important}*/
 
 .phone6s{
     padding: 84px 21px;

+ 32 - 0
src/case/ShopApp/src/api/graphql/shopCar.js

@@ -32,4 +32,36 @@ export const getShopCarByProps=`query userCartbyprops($user_id: ID, $product_id:
 
 export const deleteCarByProps=`mutation deleteuserCart($id: ID, $user_id: ID, $product_id: ID, $count: Int, $createdAt: String, $updatedAt: String) {
     deleteuserCart: delete_userCart(id: $id user_id: $user_id product_id: $product_id count: $count createdAt: $createdAt updatedAt: $updatedAt)
+}`
+
+export const createShopCar=`mutation createuserCart($id: ID!, $user_id: ID, $product_id: ID, $count: Int, $createdAt: String, $updatedAt: String) {
+    createuserCart: create_userCart(id: $id user_id: $user_id product_id: $product_id count: $count createdAt: $createdAt updatedAt: $updatedAt) {
+        id
+        user_id {
+            email
+            updatedAt
+            password
+            telephone
+            username
+            createdAt
+            openid
+            id
+        }
+        product_id {
+            category
+            updatedAt
+            unit
+            name
+            createdAt
+            status
+            id
+            intro
+            price
+            img
+            stock
+        }
+        count
+        createdAt
+        updatedAt
+    }
 }`

+ 1 - 1
src/case/ShopApp/src/components/OrderPage/OrederPage.css

@@ -1,4 +1,4 @@
-*{
+.addressWrap  *{
     font-size: 12px;
 }
 .addressWrap{

+ 26 - 3
src/case/ShopApp/src/components/ProductDetailPage/ActionSheet.jsx

@@ -1,10 +1,12 @@
 import React from 'react'
 import './ActionSheet.css'
-
-import {PageContext} from '../../context/context'
 import { ActionSheet, WingBlank, WhiteSpace, Button, Toast } from 'antd-mobile';
 import { List, Stepper } from 'antd-mobile';
 
+import {graphqls} from '../../api/graphql_request'
+import {createShopCar} from '../../api/graphql/shopCar'
+import {PageContext} from '../../context/context'
+
 
 
 
@@ -14,6 +16,7 @@ class ActionSheets extends React.Component {
     this.state = {
       num:1
     };
+    this.addCar=this.addCar.bind(this)
   }
   
  
@@ -36,6 +39,26 @@ class ActionSheets extends React.Component {
     this.props.setNum(num)
   }
 
+  addCar(){
+      let that=this
+      let createdAt=new Date().toLocaleDateString()+' '+new Date().toLocaleTimeString().slice(2)
+      let id=new Date().getTime()+parseInt(Math.random()*100000,10)
+      let user_id=sessionStorage.getItem('openid')
+      console.log(user_id)
+      //console.log('-----',this.props)
+      const variable={
+        count:that.state.num,
+        id,
+        createdAt,
+        updatedAt:createdAt,
+        user_id,
+        product_id:this.props.product.id
+      }
+      console.log(variable)
+
+    graphqls(createShopCar,variable).then(e=>console.log(e))
+  }
+
   render() {
     return (
         <div className="actionSheet">
@@ -50,7 +73,7 @@ class ActionSheets extends React.Component {
                     {(changePage)=>{
                         return(
                             <div className="buttonWraps">
-                                <button>加入购物车</button>
+                                <button onClick={this.addCar}>加入购物车</button>
                                 <button onClick={()=>changePage('order')}>立即购买</button>
                             </div>
                         )

+ 1 - 0
src/case/ShopApp/src/components/ProductDetailPage/UserAction.jsx

@@ -22,6 +22,7 @@ class UserAction extends Component{
     }
 
     renderPage(){
+        
         let actionSheet=this.state.actionSheet
         if(actionSheet){
             return(<div><ActionSheets triggerActionSheet={this.triggerActionSheet} product={this.props.product} setNum={this.props.setNum}/></div>)

+ 4 - 1
src/case/ShopApp/src/components/ShopCarPage/ShopCarCard.jsx

@@ -12,7 +12,10 @@ export default class ShopCarCard extends Component {
   //删除购物车
   deleteCarById(id){
     console.log(id)
-    graphqls(deleteCarByProps,{id}).then((e)=>console.log(e))
+    graphqls(deleteCarByProps,{id}).then((e)=>{
+      console.log(e)
+      this.props.getCarByProps()
+    })
   }
   render() {
     const car=this.props.car

+ 1 - 1
src/case/ShopApp/src/components/ShopCarPage/ShopCarPage.jsx

@@ -43,7 +43,7 @@ class ShopCarPage extends Component{
 
     renderShopCarList(){
         return this.state.shopCarList.map((item,index)=>{
-            return <ShopCarCard car={item} key={index}/>
+            return <ShopCarCard car={item} key={index} getCarByProps={this.getCarByProps.bind(this)}/>
         })
     }
     

+ 21 - 0
src/case/ShopApp/src/components/Toast/Success.jsx

@@ -0,0 +1,21 @@
+import React, { Component } from 'react'
+import { Toast, WhiteSpace, WingBlank, Button } from 'antd-mobile';
+
+export default class Success extends Component {
+  
+
+  render() {
+    return (
+      <div>
+        <WingBlank>
+            <Button onClick={successToast}>success</Button>
+            <WhiteSpace />
+        </WingBlank>
+      </div>
+    )
+  }
+}
+
+
+
+