商城小程序是基于微信、抖音和头条等第三方平台为基础构建的社区电商购物系统。在本文中我们将讨论小程序商场源码的架构思路和基本方法。

源码及演示:xcxyms.top

商城小程序源码所要提供的功能

1、用户可以下单并购买商品。

2、用户将能够添加购物车。

3、用户便捷的支付系统。

4、用户可以查看订单状态和历史记录。

设计思路:

首先,将向客户显示菜单。选择后,所有产品及其价格将显示出来。然后客户将选择产品并选择数量(产品数量)。这个过程一直持续到购物完成。每当顾客完成他的购物的数量和单价后,最后要支付的总额显示出来。

以下是上述功能的实现:

// C++ program to implement the program
// that illustrates Online shopping
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <map>
using namespace std;char c1, confirm_quantity;
float quantity;
int selectedNum;
double total_amount = 0;
int flag = 0;// Stores items with their corresponding
// price
map<string, double> items = {{ "Samsung", 15000 },{ "Redmi", 12000 },{ "Apple", 100000 },{ "Macbook", 250000 },{ "HP", 40000 },{ "Lenovo", 35000 },{ "C", 1000 },{ "C++", 3000 },{ "Java", 4000 },{ "Python", 3500 }
};// Stores the selected items with
// their quantity
map<string, int> selected_items;// Function to print the bill after shopping
// is completed prints the items, quantity,
// their cost along with total amount
void printBill(map<string, double> items,map<string, int> selected_items,float total_amount)
{cout << "Item    "<< "Quantity   "<< "Cost\n";for (auto j = selected_items.begin();j != selected_items.end(); j++) {cout << j->first << "   ";cout << j->second << "       ";cout << (selected_items[j->first])* (items[j->first])<< endl;}cout << "-----------------------"<< "-------------\n";cout << "Total amount:          "<< total_amount << endl;cout << "-----------------------"<< "-------------\n";cout << "*****THANK YOU && HAPPY"<< " ONLINE SHOPPING*****";
}// Function to ask the basic details of
// any customer
void customerDetails()
{cout << "Enter your name: ";string customer_name;getline(cin, customer_name);cout << "WELCOME ";for (int i = 0;i < customer_name.length();i++) {cout << char(toupper(customer_name[i]));}cout << "\n";
}// showMenu() is to print the
// menu to the user
void showMenu()
{cout << "Menu\n";cout << "= = = = = = = = "<< " = = = = = \n";cout << "1.Mobile\n2.laptop\n3"<< ".Computer courses\n";cout << "= = = = = = = = "<< " = = = = = \n";
}// Function to display the mobile products
void showMobileMenu()
{cout << "- - - - - - - - - - -"<< " - -\nItem    Cost\n";cout << "1.Samsung Rs.15, 000/-\n";cout << "2.Redmi Rs.12, 000/-\n";cout << "3.Apple Rs.1, 00, 000/-\n";cout << "- - - - - - - - - - - - -\n";
}// Function to display Laptop products
void showLaptopMenu()
{cout << "- - - - - - - - - - -"<< " - -\nItem    Cost\n";cout << "1.Macbook Rs.2, 00, 000/-\n";cout << "2.HP     Rs.40, 000/-\n";cout << "3.Lenovo Rs.35, 000/-\n";cout << "- - - - - - - - - - - - -\n";
}// if the user selects computer courses,
// then courses list will be displayed
void showComputerCourseMenu()
{cout << "- - - - - - - - - - "<< " - -\nItem     Cost\n";cout << "1.C    Rs.1, 000/-\n";cout << "2.C++     Rs.3, 000/-\n";cout << "3.Java  Rs.4, 000/-\n";cout << "4.Python Rs.3, 500/-\n";cout << "- - - - - - - - - - - - -\n";
}// Function to display the mobile category
void selectedMobile()
{cout << "Do you wish to conti"<< "nue?(for yes" + "press (Y/y ), "<< " if no press other letter ): ";cin >> c1;if (c1 == 'Y' || c1 == 'y') {cout << "Enter respective number: ";cin >> selectedNum;if (selectedNum == 1|| selectedNum == 2|| selectedNum == 3) {// Selected Samsungif (selectedNum == 1) {cout << "selected Samsung\n";do {cout << "Quantity: ";cin >> quantity;cout << "You have selected Samsung - "<< quantity << endl;cout << "Are you sure?"<< "(for yes press (Y/y ), "<< " if no press other letter): ";cin >> confirm_quantity;} while ((confirm_quantity != 'y'&& confirm_quantity != 'Y')|| (quantity < 0)|| (ceil(quantity) != floor(quantity)));if (confirm_quantity == 'y'|| confirm_quantity == 'Y') {total_amount += quantity* items["Samsung"];selected_items["Samsung"] = quantity;cout << "amount = "<< total_amount << endl;}}// Selected Redmiif (selectedNum == 2) {cout << "selected Redmi\n";do {cout << "Quantity: ";cin >> quantity;cout << "You have selec"<< "ted Redmi - "<< quantity << endl;cout << "Are you sure?(f"<< "or yes press (Y/y ), "<< " if no press other letter ): ";cin >> confirm_quantity;} while ((confirm_quantity != 'y'&& confirm_quantity != 'Y')|| (quantity < 0)|| (ceil(quantity)!= floor(quantity)));if (confirm_quantity == 'y'|| confirm_quantity == 'Y') {total_amount += quantity* items["Redmi"];selected_items["Redmi"] = quantity;cout << "amount = "<< total_amount << endl;}}// Selected Appleif (selectedNum == 3) {cout << "You have selected Apple\n";do {cout << "Quantity: ";cin >> quantity;cout << "You have selected"<< " Apple - "<< quantity<< endl;cout << "Are you sure?"<< "(for yes press (Y/y )"<< ", if no press other letter ): ";cin >> confirm_quantity;} while ((confirm_quantity != 'y'&& confirm_quantity != 'Y')|| (quantity < 0)|| (ceil(quantity)!= floor(quantity)));if (confirm_quantity == 'y'|| confirm_quantity == 'Y') {total_amount += quantity* items["Apple"];selected_items["Apple"] = quantity;cout << "amount = "<< total_amount<< endl;}}}else {flag = 1;}}else {flag = 1;}
}// If Laptop category is selected
void selectedLaptop()
{cout << "Do you wish to continue?"<< "(for yes press (Y/y ), "<< "if no press other letter): ";cin >> c1;if (c1 == 'Y' || c1 == 'y') {cout << "Enter respective number: ";cin >> selectedNum;if (selectedNum == 1|| selectedNum == 2|| selectedNum == 3) {// selected Macbookif (selectedNum == 1) {cout << "selected Macbook\n";do {cout << "Quantity: ";cin >> quantity;cout << "You have selected"<< " Macbook - "<< quantity << endl;cout << "Are you sure?"<< "(for yes press (Y/y ), "<< " if no press other letter ): ";cin >> confirm_quantity;} while ((confirm_quantity != 'y'&& confirm_quantity != 'Y')|| (quantity < 0)|| (ceil(quantity)!= floor(quantity)));if (confirm_quantity == 'y'|| confirm_quantity == 'Y') {total_amount += quantity* items["Macbook"];selected_items["Macbook"] = quantity;cout << "amount = "<< total_amount<< endl;}}// selected HPif (selectedNum == 2) {cout << "selected HP\n";do {cout << "Quantity: ";cin >> quantity;cout << "You have selected"<< " HP - "<< quantity << endl;cout << "Are you sure?"<< "(for yes press (Y/y ), "<< " if no press other letter ): ";cin >> confirm_quantity;} while ((confirm_quantity!= 'y'&& confirm_quantity != 'Y')|| (quantity < 0)|| (ceil(quantity)!= floor(quantity)));if (confirm_quantity == 'y'|| confirm_quantity == 'Y') {total_amount += quantity* items["HP"];selected_items["HP"] = quantity;cout << "amount = "<< total_amount<< endl;}}// selected Lenovoif (selectedNum == 3) {cout << "selected Lenovo\n";do {cout << "Quantity: ";cin >> quantity;cout << "You have selected"" Lenovo - "<< quantity << endl;cout << "Are you sure?"<< "(for yes press (Y/y ), "<< "if no press other letter ): ";cin >> confirm_quantity;} while ((confirm_quantity != 'y'&& confirm_quantity != 'Y')|| (quantity < 0)|| (ceil(quantity)!= floor(quantity)));if (confirm_quantity == 'y'|| confirm_quantity == 'Y') {total_amount += quantity* items["Lenovo"];selected_items["Lenovo"] = quantity;cout << "amount = "<< total_amount<< endl;}}}else {flag = 1;}}else {flag = 1;}
}// If computer course
// category is selected
void selectedCourses()
{cout << "Do you wish to continue?"<< "(for yes press (Y/y ), "<< " if no press other letter ): ";cin >> c1;if (c1 == 'Y' || c1 == 'y') {cout << "Enter the respective number: ";cin >> selectedNum;if (selectedNum == 1|| selectedNum == 2|| selectedNum == 3|| selectedNum == 4) {// selected Cif (selectedNum == 1) {cout << "selected C Language"<< " course\n";total_amount += items["C"];selected_items["C"]++;cout << "amount = "<< total_amount<< endl;}// selected C++if (selectedNum == 2) {cout << "selected C++ Language course\n";total_amount += items["C++"];selected_items["C++"]++;cout << "amount = " << total_amount << endl;}// selected Javaif (selectedNum == 3) {cout << "selected Java Language course\n";total_amount += items["Java"];selected_items["Java"]++;cout << "amount = " << total_amount << endl;}// selected pythonif (selectedNum == 4) {cout << "selected Python"<< " Language course\n";total_amount += items["Python"];selected_items["Python"]++;cout << "amount = "<< total_amount<< endl;}}else {flag = 1;}}else {flag = 1;}
}// Driver code
int main()
{// function callcustomerDetails();do {showMenu();cout << "Do you wish to continue?"<< "(for yes press (Y/y ), "<< " if no press other letter ): ";char c;cin >> c;if (c == 'Y' || c == 'y') {cout << "Enter respective number: ";int num;cin >> num;if (num == 1 || num == 2|| num == 3) {switch (num) {case 1:// For MobileshowMobileMenu();selectedMobile();break;case 2:// For LaptopshowLaptopMenu();selectedLaptop();break;case 3:// For computer courseshowComputerCourseMenu();selectedCourses();break;}}else {flag = 1;}}else {flag = 1;}} while (flag == 0);// print billprintBill(items, selected_items,total_amount);
}

输出:

假设有人需要购买2台Redmi手机、1台HP笔记本电脑和一门Java课程。

演示:

第一步:首先,一张地图(say map<string, long double> items)是构造的,它存储产品及其成本。构建另一个映射(say map<string, long double>selected_items ),它用于按数量推送所选项目。然后将total_amount(存储总金额)初始化为0。使用标志并初始化为0。如果客户输入错误,则标志变为1,并通过打印项目及其价格直接退出,然后打印总金额。

第二步:询问详细信息,例如客户的姓名。在我们的准则中customerDetails() 函数就是为此目的而构造的。toupper()用于将字符串中的所有字符转换为大写。

第三步:向用户显示菜单。showMenu() 函数是为此目的而创建的。

第四步:询问用户是否愿意继续。在这里do while循环被使用,这个循环将继续,直到标志变为1。每当标志变为1时,它直接打印账单。

如果是,他需要进去是/是然后要求用户从菜单中输入相应的数字。如果输入了错误的数字,则标志变为1。

如果输入有效,则显示所选类型的产品。请用户输入相应的数字。如果无效,则标志将更改为1。

商城小程序源码|开源小程序商城完整源码附视频搭建教程相关推荐

  1. 360影视php视频系统源码,全新360影视2.0完整源码 双端APP+三级分销 附视频搭建教程...

    源码资源说明: 演示环境Linux+mysql+PHP5.6+伪静态支持这个程序基本环境要求不是很大,但有的地方还是要注意一下说一下需要的东西: 1.主机 2.域名 3.源码(会给大家打包,包含前后端 ...

  2. 云盘网盘系统源码快速对接多家云存储(带视频搭建教程)

    介绍: PHP云盘网盘系统源码快速对接多家云存储 带视频搭建教程 快速对接多家云存储,支持七牛.又拍云.阿里云OSS.AWS S3.Onedrive.自建远程服务器,当然,还有本地存储. 自定义主题配 ...

  3. WoShop多商户直播电商系统APP+小程序+H5全开源无加密商城源码

    WoShop多商户直播电商系统APP+小程序+H5全开源无加密商城源码 随着多商户直播电商系统的市场走向兴盛,不止直播电商系统的使用越来越广泛,寻求多商户直播电商系统源码的人也越来越多.但源码市场混乱 ...

  4. chatgpt智能问答微信小程序+后端源码+视频搭建教程

    chatgpt智能问答微信小程序+后端源码+视频搭建教程,这是一套微信小程序,后端是thinkphp框架为接口的,后端是前后端分离用elmentUI的源码框架. 小狐狸GPT付费体验系统是一款基于Th ...

  5. 新版带支付功能2021全新最火表情包小程序源码,无限裂变,斗图小程序,头像壁纸,外卖服务内附详细搭建教程

    内附详细搭建教程 1.全新表情包小程序已上线 2.增加外卖系统服务,进行进一步的扩展内容分销 3.独立后台系统,自己运营管理,广告位自己控制 4.流量主可以代开,小程序包通过审核,不通过不收钱 5.不 ...

  6. 彩虹易支付多通道轮训全开源运营版多模板/免签约支付系统/完善手动提现t0t1/带视频搭建教程

    介绍: 彩虹易全开源版本,朋友在互站买回来的东西.自带多款模板可随意切换,且全开源无加密无授权,对接有商户进件签约通道及Z免签约渠道,开关商户付费注册设置,接口配置,短信接口配置等等,都可以在后台一键 ...

  7. Java开发的超级马里奥小游戏410 相对简单 功能非常齐全 完整源码

    今天为大家继续分享泡泡堂小游戏的开发与制作 410,目前系统已经完成了初步功能,后续会进一步完善.整个系统界面漂亮,有完整得源码,希望大家可以喜欢.喜欢的帮忙点赞和关注.一起编程.一起进步!! 开发环 ...

  8. 最新游戏陪玩语音聊天系统源码+视频搭建教程

    一个人的游戏叫孤独,一群人的游戏才是乐趣,随着电竞产业在国内的快速发展,游戏陪练行业也迅速成长,现在很多游戏玩家为了追求更高质量的游戏体验感,往往会在玩游戏的过程中找陪练,通过陪玩系统进行预约游戏陪练 ...

  9. 四端有米FZ码力微信辅助接单系统源码-附视频安装教程

    介绍: 四端有米FZ码力微信接单系统源码,带视频安装教程,独家首发 ,包括:做单端.下单端.总后台三端.结合微信流程,自动化任务平台. 源码安装方法: 环境:php5.6+ apache +MySQL ...

  10. 微信小程序左滑删除效果的实现完整源码附效果图

    效果图: 功能描述,小程序列表左滑删除功能的实现完整源代码实现: <view wx:for='{{friends}}' wx:key="" wx:if='{{groupTyp ...

最新文章

  1. android获取手机通讯录
  2. ise iMPACT bit生成MCS
  3. 【深度好文】我们的未来在哪里?
  4. The mountain is unchanged,but the heart is changed
  5. 简单区分grep 命令 *的作用
  6. 【iOS】Quartz2D图片剪切
  7. Spark精华问答 | Spark和Hadoop的架构区别解读
  8. 第 二 十 八 天 :LB 负 载 均 衡 搭 建 之 LVS
  9. js for ubuntu
  10. 【交换机在江湖】第十四章 VLAN通信篇
  11. windows安装和配置阿帕奇+PHP服务器
  12. 如何使用plink进行二分类性状的GWAS分析并计算PRS得分
  13. Java 与或非 判断
  14. php mysql可以跨站_Laravel5中防止XSS跨站攻击的方法
  15. 阿里大文娱深耕电影赛道,推出多部爆款电影
  16. Android Bluetooth HID Device模拟蓝牙键盘鼠标
  17. 优思学院:六西格玛的热潮
  18. storm和kafka集成报java.lang.ClassNotFoundException: kafka.api.OffsetRequest解决方法
  19. 关于opencv更改摄像头参数(帧率,分辨率,曝光度……)的几个问题
  20. 雅思考生在2018年创下350万人次的新高

热门文章

  1. Java 学习笔记(手写版)
  2. 功能强大的云打印组件-接口文档
  3. hex2bin() 函数
  4. IntelliJ IDEA搭建Hadoop开发环境(下)
  5. Java编程常用的软件有哪些
  6. web前端实战小游戏两则(附源码)
  7. SpringBoot 中使用 QuzartZ
  8. 用栈实现计算器c语言报告,利用栈实现c语言计算器
  9. Android+按键精灵代码,安卓按键精灵怎么编写脚本 编写脚本教程
  10. AC9560网卡linux驱动安装