当前位置:   article > 正文

uni-app单商家点餐系统(已完结-附带源码)_uniapp点餐小程序源码

uniapp点餐小程序源码
  • 可以三端打包,移动网页、微信小程序、app

部分代码

  1. <template>
  2. <view class="content">
  3. <!-- 分类导航 -->
  4. <view class="classify-list">
  5. <!-- 左侧分类导航 -->
  6. <scroll-view scroll-y="true" class="left">
  7. <view class="row" v-for="(item,index) in classifyList" :key="index"
  8. :class="[index === showClassifyIndex ? 'active' : '']" @tap="tapClassify(index)">
  9. <view class="text">
  10. <view class="block" :class="'bg-' + themeColor.name"></view>
  11. {{item.title}}
  12. </view>
  13. </view>
  14. </scroll-view>
  15. <!-- 右侧分类导航 -->
  16. <scroll-view scroll-y="true" class="right">
  17. <view v-for="(item, index) in classifyList" :key="index">
  18. <view v-if="index === showClassifyIndex" class="classify">
  19. <view class="" v-if="item.goods_list.length !== 0">
  20. <!-- 标题 -->
  21. <view class="item-title unify-weight">{{item.title}}</view>
  22. <view class="item-subclass unify-relative"
  23. v-for="(item2,index2) in item.goods_list" :key="index2">
  24. <view class="item-subclass-ice unify-flex" @tap="tapGoodsDetails(item2)">
  25. <view class="item-left">
  26. <image class="item-left-image" :src="item2.goods_cover || errorImage" mode="">
  27. </image>
  28. </view>
  29. <view class="item-right">
  30. <view class="item-right-con">
  31. <view class="item-right-name unify-weight unify-font-size-line-astrict">
  32. {{item2.goods_name}}
  33. </view>
  34. <view class="item-right-desc unify-font-size-two-line-astrict">
  35. {{item2.goods_desc}}
  36. </view>
  37. <view class="item-right-price unify-absolute unify-flex">
  38. <view class="item-price unify-weight" :class="'tf-' + themeColor.name">
  39. <text class="item-price-iden">{{moneySymbol}}</text>
  40. {{item2.goods_price}}
  41. <text
  42. class="item-original-price">{{moneySymbol}}{{item2.goods_original_price}}</text>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <uni-goods-add-subtract :data="item2" :index="index" :index2="index2" :absolute="true" bottom="10rpx" right="40rpx" @minus="tapNumber" @add="tapNumber"></uni-goods-add-subtract>
  49. </view>
  50. <!-- 间隔 -->
  51. <view style="height: 60px" v-if="goodsNum > 0"></view>
  52. </view>
  53. <view class="no-data" v-else>
  54. <image class="iconfont" :src="iconRight" mode="widthFix"></image>
  55. 暂无分类
  56. </view>
  57. </view>
  58. </view>
  59. </scroll-view>
  60. </view>
  61. <uni-goods-add-subtract-animation :show="isCartIcon" :cartItemElc="cartItemElc"></uni-goods-add-subtract-animation>
  62. <!-- 购物车 -->
  63. <uni-shopping-trolley ref="uniShoppingTrolley" :show="show" :cartItemElc="cartItemElc" :isCartIcon="isCartIcon"
  64. :num="goodsNum" :totalPrice="totalPrice" :isMinus="isMinus" @updateIsCartIcon="updateIsCartIcon" @updateCartItemElc="updateCartItemElc">
  65. </uni-shopping-trolley>
  66. </view>
  67. </template>
  68. <script>
  69. export default {
  70. data() {
  71. return {
  72. windowHeight: this.windowHeight, // 屏幕高度
  73. statusBarHeight: this.statusBarHeight, // 状态栏
  74. errorImage: this.$mAssetsPath.errorImage,
  75. iconRight: this.$mAssetsPath.iconRight,
  76. moneySymbol: this.$mConstDataConfig.moneySymbol,
  77. appName: this.$mSettingConfig.appName,
  78. show: false, // 购物车是否显示
  79. isCartIcon: false, // 动画标
  80. cartItemElc: { // 坐标
  81. left: 0,
  82. top: 0
  83. },
  84. goodsNum: 0, // 购物车数量
  85. totalPrice: 0, // 商品总价
  86. isMinus: 0, // 判断是否减操作
  87. showClassifyIndex: 0, // 一级菜单高亮显示序号
  88. classifyList: [{
  89. title: "招聘推荐",
  90. goods_list: [{
  91. goods_name: '新鲜盐焗鸡新鲜盐焗鸡新鲜盐焗鸡新鲜盐焗鸡新鲜盐焗鸡',
  92. goods_cover: '/static/mall/goods2.png',
  93. goods_desc: '盐水鸡是一道由鸡、辣椒、盐水等做成的菜肴,冷热均可食,味咸辣。可用于虚劳瘦弱、骨蒸潮热、脾虚泄泻、消渴、崩漏、赤白带、遗精等',
  94. goods_price: '19',
  95. goods_original_price: '29',
  96. goods_number: 0,
  97. goods_image: ["/static/mall/goods1.png", "/static/mall/goods2.png"],
  98. }, {
  99. goods_name: '新鲜盐焗鸡',
  100. goods_cover: '',
  101. goods_desc: '盐水鸡是一道由鸡、辣椒、盐水等做成的菜肴,冷热均可食,味咸辣。可用于虚劳瘦弱、骨蒸潮热、脾虚泄泻、消渴、崩漏、赤白带、遗精等',
  102. goods_price: '19',
  103. goods_original_price: '29',
  104. goods_number: 0,
  105. goods_image: ["/static/mall/goods1.png", "/static/mall/goods2.png"],
  106. }, {
  107. goods_name: '新鲜盐焗鸡',
  108. goods_cover: '/static/mall/goods2.png',
  109. goods_desc: '盐水鸡是一道由鸡、辣椒、盐水等做成的菜肴,冷热均可食,味咸辣。可用于虚劳瘦弱、骨蒸潮热、脾虚泄泻、消渴、崩漏、赤白带、遗精等',
  110. goods_price: '19',
  111. goods_original_price: '29',
  112. goods_number: 0,
  113. goods_image: ["/static/mall/goods1.png", "/static/mall/goods2.png"],
  114. }, {
  115. goods_name: '新鲜盐焗鸡',
  116. goods_cover: '/static/mall/goods2.png',
  117. goods_desc: '盐水鸡是一道由鸡、辣椒、盐水等做成的菜肴,冷热均可食,味咸辣。可用于虚劳瘦弱、骨蒸潮热、脾虚泄泻、消渴、崩漏、赤白带、遗精等',
  118. goods_price: '19',
  119. goods_original_price: '29',
  120. goods_number: 0,
  121. goods_image: ["/static/mall/goods1.png", "/static/mall/goods2.png"],
  122. }, {
  123. goods_name: '新鲜盐焗鸡',
  124. goods_cover: '/static/mall/goods2.png',
  125. goods_desc: '盐水鸡是一道由鸡、辣椒、盐水等做成的菜肴,冷热均可食,味咸辣。可用于虚劳瘦弱、骨蒸潮热、脾虚泄泻、消渴、崩漏、赤白带、遗精等',
  126. goods_price: '19',
  127. goods_original_price: '29',
  128. goods_number: 0,
  129. goods_image: ["/static/mall/goods1.png", "/static/mall/goods2.png"],
  130. }]
  131. },
  132. {
  133. title: "肉丸类",
  134. goods_list: []
  135. }
  136. ],
  137. }
  138. },
  139. onLoad() {
  140. },
  141. methods: {
  142. // 商品详情
  143. tapGoodsDetails(e) {
  144. this.$openPage({
  145. name: 'goodsDetails',
  146. query: {
  147. data: e
  148. }
  149. })
  150. },
  151. // 点击分类
  152. tapClassify(e) {
  153. this.showClassifyIndex = e;
  154. },
  155. // 点击商品数量加减 1减 2加
  156. tapNumber(e, type, index, index2) {
  157. let classifyList = this.classifyList;
  158. this.isMinus = type; // 判断是否减操作 1减 2加
  159. switch (type) {
  160. case 1:
  161. classifyList[index].goods_list[index2].goods_number--
  162. this.goodsNum--
  163. this.countTotalPrice() // 回调计算总价
  164. if (this.goodsNum === 0) {
  165. this.show = false;
  166. setTimeout(() => {
  167. this.$refs.uniShoppingTrolley.isCartShow() // 回调组件isCartShow方法
  168. }, 20)
  169. }
  170. break
  171. case 2:
  172. this.show = true;
  173. classifyList[index].goods_list[index2].goods_number++
  174. this.cartItemElc.left = e.touches[0].pageX - 15; // 自由调动位置
  175. this.cartItemElc.top = e.touches[0].pageY - 40;
  176. setTimeout(() => {
  177. this.goodsNum++
  178. this.countTotalPrice() // 回调计算总价
  179. this.$refs.uniShoppingTrolley.isCartShow() // 回调组件isCartShow方法
  180. }, 20)
  181. break
  182. default:
  183. break
  184. }
  185. this.classifyList = classifyList;
  186. },
  187. // 计算商品总价
  188. countTotalPrice() {
  189. let total = 0,
  190. classifyList = this.classifyList;
  191. classifyList.forEach((item, index) => {
  192. item.goods_list.forEach((item2, index2) => {
  193. total += Number(item2.goods_price) * item2.goods_number;
  194. })
  195. })
  196. this.totalPrice = total;
  197. },
  198. // 更新动画标状态 默认false
  199. updateIsCartIcon(e) {
  200. this.isCartIcon = e;
  201. },
  202. // 更新cartItemElc坐标移动
  203. updateCartItemElc(e) {
  204. this.cartItemElc = e;
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss" scoped>
  210. /* 模块分类 */
  211. .classify-list {
  212. width: 100%;
  213. height: 100%;
  214. background-color: #FFFFFF;
  215. display: flex;
  216. position: absolute;
  217. padding-top: 88rpx;
  218. /* #ifdef APP-PLUS */
  219. padding-top: calc(88rpx + var(--status-bar-height));
  220. /* #endif */
  221. bottom: 0;
  222. .left {
  223. width: 24%;
  224. left: 0rpx;
  225. background-color: #f8f8f8;
  226. .row {
  227. width: 100%;
  228. height: 90rpx;
  229. display: flex;
  230. align-items: center;
  231. .text {
  232. width: 100%;
  233. position: relative;
  234. font-size: 28rpx;
  235. display: flex;
  236. justify-content: center;
  237. color: #3c3c3c;
  238. .block {
  239. position: absolute;
  240. width: 0rpx;
  241. left: 0rpx;
  242. }
  243. }
  244. &.active {
  245. height: 100rpx;
  246. background-color: #FFFFFF;
  247. .text {
  248. font-size: 30rpx;
  249. font-weight: 600;
  250. color: #2d2d2d;
  251. .block {
  252. width: 6rpx;
  253. height: 100%;
  254. left: 10rpx;
  255. }
  256. }
  257. }
  258. }
  259. }
  260. .right {
  261. width: 76%;
  262. left: 24%;
  263. background-color: #fff;
  264. .classify {
  265. width: 100%;
  266. padding: 0 20rpx 0;
  267. padding-top: 10rpx;
  268. // 标题
  269. .item-title {
  270. line-height: 86rpx;
  271. font-size: $uni-font-size-base;
  272. }
  273. .item-subclass {
  274. margin-bottom: 40rpx;
  275. .item-subclass-ice {
  276. .item-left {
  277. .item-left-image {
  278. width: 180rpx;
  279. height: 180rpx;
  280. border-radius: 10rpx;
  281. }
  282. }
  283. .item-right {
  284. width: 65%;
  285. height: 180rpx;
  286. .item-right-con {
  287. height: inherit;
  288. margin: 10rpx 30rpx 10rpx 20rpx;
  289. .item-right-name {
  290. font-size: $uni-font-size-base;
  291. }
  292. .item-right-desc {
  293. font-size: $uni-font-size-sm;
  294. color: $uni-text-color-grey;
  295. margin-top: 10rpx;
  296. }
  297. .item-right-price {
  298. width: 57%;
  299. bottom: 10rpx;
  300. justify-content: space-between;
  301. .item-price {
  302. .item-price-iden {
  303. font-size: $uni-font-size-sm;
  304. font-weight: 500;
  305. }
  306. .item-original-price {
  307. font-size: $uni-font-size-sm;
  308. margin-left: 5rpx;
  309. font-weight: 500;
  310. color: $uni-text-color-grey;
  311. text-decoration: line-through;
  312. }
  313. }
  314. }
  315. }
  316. }
  317. }
  318. .item-operation {
  319. width: max-content;
  320. align-items: center;
  321. bottom: 10rpx;
  322. right: 50rpx;
  323. .item-number {
  324. width: 50rpx;
  325. text-align: center;
  326. font-size: $uni-font-size-base;
  327. }
  328. .iconfont {
  329. font-size: 40rpx;
  330. }
  331. }
  332. }
  333. .no-data {
  334. margin: 48rpx 0;
  335. color: #909399;
  336. display: flex;
  337. justify-content: center;
  338. align-items: center;
  339. .iconfont {
  340. margin-right: 20rpx;
  341. width: 50rpx;
  342. height: 52rpx;
  343. }
  344. }
  345. }
  346. }
  347. }
  348. </style>

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6Z2S6KGr5oqY5omH,size_12,color_FFFFFF,t_70,g_se,x_16watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6Z2S6KGr5oqY5omH,size_12,color_FFFFFF,t_70,g_se,x_16watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6Z2S6KGr5oqY5omH,size_12,color_FFFFFF,t_70,g_se,x_16

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6Z2S6KGr5oqY5omH,size_12,color_FFFFFF,t_70,g_se,x_16watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6Z2S6KGr5oqY5omH,size_12,color_FFFFFF,t_70,g_se,x_16watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6Z2S6KGr5oqY5omH,size_12,color_FFFFFF,t_70,g_se,x_16

可访问直接导入BHX使用: 单商家点餐平台 - DCloud 插件市场

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/398548
推荐阅读
相关标签
  

闽ICP备14008679号