商城小程序是基于微信、抖音和头条等第三方平台为基础构建的社区电商购物系统。在本文中我们将讨论小程序商场源码的架构思路和基本方法。
源码及演示: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 << "= = = = = = = = "