index.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. import React, {Component} from 'react'
  2. import './index.css'
  3. import {Grid, ActivityIndicator} from 'antd-mobile'
  4. import {withRouter} from 'react-router-dom'
  5. import Logo from '../../../components/logo'
  6. import {getCookie} from "../../../utils/cookie"
  7. import {user_by_id} from "../../../utils/gql"
  8. import {Query} from "react-apollo"
  9. import gql from "graphql-tag"
  10. const orderIcon = [
  11. {
  12. icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/pay.png',
  13. text: '待付款',
  14. id: 'pay'
  15. },
  16. {
  17. icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/ship.png',
  18. text: '待发货',
  19. id: 'ship'
  20. },
  21. {
  22. icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/unbox.png',
  23. text: '待收货',
  24. id: 'unbox'
  25. },
  26. {
  27. icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/judge.png',
  28. text: '待评价',
  29. id: 'judge'
  30. }
  31. ]
  32. const toolsIcon = [
  33. {
  34. icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/address.png',
  35. text: '收货地址',
  36. id: 'address'
  37. },
  38. {
  39. icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/cart.png',
  40. text: '购物袋',
  41. id: 'cart'
  42. },
  43. {
  44. icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/message.png',
  45. text: '系统通知',
  46. id: 'message'
  47. }
  48. ]
  49. const memberIcon = [
  50. {
  51. icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/card.png',
  52. text: '会员卡',
  53. id: 'card'
  54. },
  55. {
  56. icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/coupon.png',
  57. text: '优惠券',
  58. id: 'coupon'
  59. },
  60. {
  61. icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/credit.png',
  62. text: '积分',
  63. id: 'credit'
  64. }
  65. ]
  66. const shopIcon = [
  67. {
  68. icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/shop.png',
  69. text: '店铺展示',
  70. id: 'shop'
  71. },
  72. {
  73. icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/goods.png',
  74. text: '商品管理',
  75. id: 'goods'
  76. },
  77. {
  78. icon: 'https://ece-img-1254337200.cos.ap-chengdu.myqcloud.com/icon/order.png',
  79. text: '订单管理',
  80. id: 'orders'
  81. }
  82. ]
  83. class All extends Component {
  84. constructor(props) {
  85. super(props)
  86. this.state = {}
  87. }
  88. render() {
  89. let user_id = getCookie('user_id')
  90. // console.log(user_id)
  91. return (
  92. <div className='my-wrap all'>
  93. <Query query={gql(user_by_id)} variables={{id: user_id}}>
  94. {
  95. ({loading, error, data}) => {
  96. if (loading) {
  97. return (
  98. <div className="loading-center">
  99. <ActivityIndicator text="Loading..." size="large"/>
  100. </div>
  101. )
  102. }
  103. if (error) {
  104. return 'error!'
  105. }
  106. data = data.userbyid
  107. return (
  108. <div className='avatar-area' onClick={()=>{
  109. this.props.history.push({
  110. pathname: `/my/profile`,
  111. state: {}
  112. })
  113. }}>
  114. <div className='avatar'/>
  115. <div className='nickname'>{data.username}</div>
  116. </div>
  117. )
  118. }
  119. }
  120. </Query>
  121. <div className='my-card order-card'>
  122. <div className='card-title'>
  123. 电商订单
  124. </div>
  125. <div className='card-icons'>
  126. <Grid data={orderIcon}
  127. columnNum={4}
  128. hasLine={false}
  129. onClick={(order) => {
  130. this.props.history.push({
  131. pathname: '/my/order',
  132. state: {
  133. kind: order.id
  134. }
  135. })
  136. }}
  137. />
  138. </div>
  139. </div>
  140. <div className='my-card tools-card'>
  141. <div className='card-title'>
  142. 我的工具
  143. </div>
  144. <div className='card-icons'>
  145. <Grid data={toolsIcon}
  146. columnNum={4}
  147. hasLine={false}
  148. onClick={(tools) => {
  149. if (tools.id === 'cart') {
  150. this.props.history.push({
  151. pathname: '/cart'
  152. })
  153. } else {
  154. this.props.history.push({
  155. pathname: '/my/tools',
  156. state: {
  157. page: tools.id
  158. }
  159. })
  160. }
  161. }}
  162. />
  163. </div>
  164. </div>
  165. <div className='my-card member-card' style={{display: 'none'}}>
  166. <div className='card-title'>
  167. 会员中心
  168. </div>
  169. <div className='card-icons'>
  170. <Grid data={memberIcon}
  171. columnNum={4}
  172. hasLine={false}
  173. onClick={(member) => {
  174. this.props.history.push({
  175. pathname: '/my/member',
  176. state: {
  177. page: member.id
  178. }
  179. })
  180. }}
  181. />
  182. </div>
  183. </div>
  184. <div className='my-card member-card'>
  185. <div className='card-title'>
  186. 商家入口
  187. </div>
  188. <div className='card-icons'>
  189. <Grid data={shopIcon}
  190. columnNum={4}
  191. hasLine={false}
  192. onClick={(shop) => {
  193. this.props.history.push({
  194. pathname: '/my/manage',
  195. state: {
  196. page: shop.id
  197. }
  198. })
  199. }}
  200. />
  201. </div>
  202. </div>
  203. <Logo/>
  204. </div>
  205. )
  206. }
  207. }
  208. export default withRouter(All)