Design and Implementation of "Fresh Vegetables" APP

1 Introduction

In this era where technology and the Internet go hand in hand, food delivery services are developing rapidly. People have more and more requirements for the functions of the food delivery APP system, and the developers of the APP have higher and higher requirements for themselves. The system needs to be designed according to the realized functions and user needs, and it also needs to be designed in combination with the current rapidly developing network to make it easy for users to use. Therefore, in today’s environment of rapid network development, developing an app that sells vegetables and fruits for farmers will have a good development space, and now there are endless takeaway apps, and there are more than a thousand takeaway apps on the market plus small programs. There are more than 100 million people using large-scale food delivery apps nationwide, and young people account for more than 50%. Young people are the most active group. There are also various small food delivery programs in the school. After a period of investigation, the usage rate is also very high, and almost every student has used it. Therefore, when developing a vegetable delivery app, many people will get started quickly. Even the elderly can get started quickly after teaching their children. It is easy to use and has complete functions. This is also the best way to develop a fresh vegetable app. A challenge.

The realization of the main functions of the entire APP system and the maintenance of the later system need to design an APP dedicated to selling vegetables in combination with the actual needs of users. The design of this APP system needs to meet the characteristics of simple operation. With the rapid development of the Internet today, many people like the convenience brought by the Internet. For example, the food delivery APP that exists in the market is used more and more by people, and the development prospect is very good. Moreover, the development of Fresh Vegetable APP can also allow many unemployed people to deliver, which can solve part of the employment problem. Merchants can choose to deliver by themselves or hire someone to deliver. Using this APP system solves the employment problem beyond the original purpose. Therefore, for this fresh vegetable APP delivery system, it is very suitable for the demand, and it is very suitable for the world of the rapid development of the Internet.

2. Development technology

2.1 Java language

The Java language is published by Sun. It has the advantage of open source code. This advantage has attracted great interest from programming enthusiasts all over the world. The Java language has many features, which are very different from other languages, as follows:

(1) Platform-independent: After writing the code, it can not only run on the platform used for writing, but even if it is switched to other platforms, as long as the compilation environment of the official website is downloaded in the new system, it can be executed in the same way.

(2) Object-oriented: Compared with process-oriented, object-oriented problem-solving ideas may be troublesome in the early stage of writing code, but the efficiency will be doubled in the later stage.

(3) Source code open source: When writing a Java program, sometimes some deep code is used, you can directly check the source code, and then go to the official website to find the corresponding Chinese explanation, and you can understand the principle well. to use.

(4) The code is simple: to learn the Java language, as long as you have learned a language systematically, you will get started quickly when you learn it again, and the writing format is roughly the same. Even if you haven't learned it, you can get started relatively quickly compared to other languages.

Among them, object-oriented can easily help us solve some practical problems in life [2]. Cross-platformity is also useful. Can run in all operating systems. Java technology is also a server language that is easy for people to learn and use. It can be used to link most of the servers on the market for background writing.

2.2 Node.js and JavaScript

Node.js is not a programming language, but a platform. Node.js makes it possible for JavaScript to appear on the backend, and can be executed independently on the server side. Its learning curve is very simple, after a simple study, you can get started and use it simply.

JavaScript is not a programming language, it is a scripting language, and it is one of the most used languages ​​​​by web developers. It requires a running environment. Before the emergence of Node.js, JavaScript could only run on the browser. After the emergence of Node.js, there is a new environment that can run, the Node.js platform.

2.3 SQLite database

SQLite not only has embedded features but also lightweight features. Take up less space. It can be used in many mainstream systems and can be combined with many languages. Due to the advantage of occupying less memory, the processing speed is faster than that of the general database system. Correspondingly, it is not possible to store a large amount of data.

3. Functional design

3.1 Overall design idea

The initial development goal of this system is to develop a dedicated APP for farmers who are inconvenient to sell vegetables, and it should be easy for them to use. After analysis, it can not only sell vegetables, but also fruits, etc., agricultural products. Through this APP, farmers do not need to bring their own dishes to the market to sell every day, but only need to sell them at home.

The design of this APP system starts from data analysis. After the analysis is completed, specific code writing starts from the layout of a login interface, and then the registration interface, APP main interface, product list interface, and personal center interface. These interface codes are divided into Each layout file is installed in the layout folder. Collect the pictures and other information that needs to be used on the Internet, import them into drawable, and then in the Activity folder, first define some variables of each layout file, and then obtain each layout file. For store information and product information, run the written js code through acquired Node.js, execute the corresponding file in the dos command window, obtain the content in the Java code, and finally import it into the corresponding layout file. Then write the corresponding functions of the modules, then declare each independent page and connect them together, and finally write the entry code of the entire program in the code of the login interface, and then connect the modules together to form a Complete APP system.

3.2 Functional module structure diagram

(1) User login: Click the APP icon to enter the login interface. If you do not have an account, you can register. There is also the function of remembering the password and automatically logging in.

(2) Store page and personal center: After successful login, you can see the store where the goods are being sold, and you can also click on the personal center icon to modify your personal information.

(3) Product list and details: Click on the store in the list to see the products that are on sale in the store, and you can purchase the favorite products in the store. Click on the corresponding product to see the product details.

(4) Shopping cart and payment: After clicking to buy, it will be automatically put into the shopping cart, and after the selection is completed, the payment and settlement system structure is shown in the figure.

4. Functional renderings

4.1 Login interface

Click the icon to enter the login interface. You can click the text below the login, and then click Back to log in after registration. After logging in, you can see the list of stores that are selling products, as shown in the figure.

 4.2 System main interface

After the user enters the APP and successfully logs in, he can visually see the shops that are selling dishes and fruits, and choose his favorite shop, as shown in the figure.

4.3 Product list interface

After clicking the store you want to enter, you will see the dishes and fruits that are being sold in the store, and then add them to the shopping cart. After clicking the product you want to buy, the detailed introduction of the product will appear, introducing the specific information of the product, such as As shown in the figure.

4.4 Shopping cart interface

 Add the desired product to the shopping cart, then enter the delivery address, and then make payment, modification, etc., click payment, and a payment window will pop up to display the payment code of the corresponding store, as shown in the figure.

 

 4.5 Personal center and modification interface

The personal center can display avatar, account number, date of birth, personal signature, frequently used address, click to edit the information, you can change the information other than the account number, as shown in the figure.

 

5. Core code

public final class BuildConfig {
  public static final boolean DEBUG = Boolean.parseBoolean("true");
  public static final String APPLICATION_ID = "com.example.biyesheji";
  public static final String BUILD_TYPE = "debug";
  public static final int VERSION_CODE = 1;
  public static final String VERSION_NAME = "1.0";
}
public class MainActivity extends AppCompatActivity {


    private RelativeLayout rlTitleBar;
    private TextView tvTitle;
    private ListView lvShopList;
    private ShopAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initView();
        initData();

    }


    private void initView(){
        rlTitleBar = findViewById(R.id.rl_title_bar);
        tvTitle=findViewById(R.id.tv_title);
        lvShopList=findViewById(R.id.lv_shop_list);
        adapter =new ShopAdapter(this);
        lvShopList.setAdapter(adapter);
        tvTitle.setText("店铺");
        rlTitleBar.setBackgroundColor(getResources().getColor(R.color.blue_color));
    }
    private void initData(){
        OkHttpClient client=new OkHttpClient();
        Request request=new Request.Builder().url(Constants.WEB_SITE+Constants.REQUEST_SHOP_DATA).build();
        Call call=client.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String json=response.body().string();
                Log.d("mzxy","json"+json);
                List<ShopBean> list= JsonParse.getInstance().getShopList(json);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        adapter.setData(list);

                    }
                });
            }
        });
    }
}
public class ShopDetailAcitivity extends AppCompatActivity implements View.OnClickListener {

    private TextView tvShopName,tvTime,tvNotice,tvTile;
    private ImageView ivShopPic,ivBack;


    private ShopBean bean;



    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //绑定布局文件,把布局文件当作我们这个activity的界面
        setContentView(R.layout.acitivity_shop_detail);

        bean= (ShopBean) getIntent().getSerializableExtra("shop");
        if(bean==null){
            return;
        }


        initView();

        setData();
    }

    private void setData() {
        tvShopName.setText(bean.getShopName());
        tvTime.setText(bean.getTime());
        tvNotice.setText(bean.getShopNotice());
        Glide.with(this).load(bean.getShopPic()).error(R.mipmap.ic_launcher).into(ivShopPic);
    }

    private void initView() {
        tvShopName=findViewById(R.id.tv_shop_name);
        tvTime=findViewById(R.id.tv_time);
        tvNotice=findViewById(R.id.tv_notice);
        tvTile=findViewById(R.id.tv_title);

        ivShopPic=findViewById(R.id.iv_shop_pic);
        ivBack=findViewById(R.id.iv_back);

        tvTile.setText("店铺详情");
        ivBack.setVisibility(View.VISIBLE);
        ivBack.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.iv_back:
                finish();
                break;
        }
    }
}
public class ShopAdapter extends BaseAdapter {
    private Context context;
    private List<ShopBean> data=new ArrayList<>();

    public ShopAdapter(Context context) {
        this.context = context;
    }

    public void setData(List<ShopBean> data) {
        this.data.clear();
        this.data.addAll(data);   //我们不能改变this.data的地址,否则会导致无法刷新数据
//        数据有变化,要让我们的数据进行刷新
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder=null;
        if(convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.shop_item,null);
            viewHolder=new ViewHolder();
            viewHolder.tvOfferPrice=convertView.findViewById(R.id.tv_offer_price);
            viewHolder.tvShopName=convertView.findViewById(R.id.tv_shop_name);
            viewHolder.tvSaleNum=convertView.findViewById(R.id.tv_sale_num);
            viewHolder.tvWelfare=convertView.findViewById(R.id.tv_welfare);
            viewHolder.tvTime=convertView.findViewById(R.id.tv_time);
            viewHolder.ivShopPic=convertView.findViewById(R.id.iv_shop_pic);

            convertView.setTag(viewHolder);
        }else{
            viewHolder=(ViewHolder) convertView.getTag();
        }
        ShopBean shopBean=data.get(position);
        Glide.with(context).load(shopBean.getShopPic()).error(R.mipmap.ic_launcher).into(viewHolder.ivShopPic);
        viewHolder.tvTime.setText(shopBean.getTime());
        viewHolder.tvWelfare.setText(shopBean.getWelfare());
        viewHolder.tvSaleNum.setText("月售"+shopBean.getSaleNum());
        viewHolder.tvShopName.setText(shopBean.getShopName());
        viewHolder.tvOfferPrice.setText("起送"+shopBean.getOfferPrice()+"元,配送"+shopBean.getDistributionCost()+"元");

        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent=new Intent(context, ShopDetailAcitivity.class);
                intent.putExtra("shop",shopBean);
                context.startActivity(intent);
            }
        });






        return convertView;



    }

    class ViewHolder{
        TextView tvShopName,tvSaleNum,tvOfferPrice,tvWelfare,tvTime;
        ImageView ivShopPic;
    }
}
public class FoodBean implements Serializable{


    private String foodId;
    private String foodName;
    private String taste;
    private String saleNum;
    private BigDecimal price;
    private int count;
    private String foodPic;

    public String getFoodId() {
        return foodId;
    }

    public void setFoodId(String foodId) {
        this.foodId = foodId;
    }

    public String getFoodName() {
        return foodName;
    }

    public void setFoodName(String foodName) {
        this.foodName = foodName;
    }

    public String getTaste() {
        return taste;
    }

    public void setTaste(String taste) {
        this.taste = taste;
    }

    public String getSaleNum() {
        return saleNum;
    }

    public void setSaleNum(String saleNum) {
        this.saleNum = saleNum;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public String getFoodPic() {
        return foodPic;
    }

    public void setFoodPic(String foodPic) {
        this.foodPic = foodPic;
    }
}
public class ShopBean implements Serializable {


    private Integer id;
    private String shopName;
    private int saleNum;
    private BigDecimal offerPrice;
    private int distributionCost;
    private String welfare;
    private String time;
    private String shopPic;
    private String shopNotice;
    private List<FoodBean> foodList;

    public List<FoodBean> getFoodList() {
        return foodList;
    }

    public void setFoodList(List<FoodBean> foodList) {
        this.foodList = foodList;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String shopName) {
        this.shopName = shopName;
    }

    public Integer getSaleNum() {
        return saleNum;
    }

    public void setSaleNum(Integer saleNum) {
        this.saleNum = saleNum;
    }

    public BigDecimal
    getOfferPrice() {
        return offerPrice;
    }

    public void setOfferPrice(BigDecimal offerPrice) {
        this.offerPrice = offerPrice;
    }

    public Integer getDistributionCost() {
        return distributionCost;
    }

    public void setDistributionCost(Integer distributionCost) {
        this.distributionCost = distributionCost;
    }

    public String getWelfare() {
        return welfare;
    }

    public void setWelfare(String welfare) {
        this.welfare = welfare;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getShopPic() {
        return shopPic;
    }

    public void setShopPic(String shopPic) {
        this.shopPic = shopPic;
    }

    public String getShopNotice() {
        return shopNotice;
    }

    public void setShopNotice(String shopNotice) {
        this.shopNotice = shopNotice;
    }




}
public class ShopListView extends ListView {
    public ShopListView(Context context) {
        super(context);
    }

    public ShopListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ShopListView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int heightSpec=MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE>>2,MeasureSpec.AT_MOST);   //view是用30位进行存储,那么我们应该给他30位的最大值,Int的最大值是32位,
        super.onMeasure(widthMeasureSpec, heightSpec);
    }
}

6. Reference Papers

Table of contents

1 Introduction

1.1 Subject background

1.2 Research Status

1.3 Research content

2 development environment

2.1 Java language introduction

2.2 Introduction to Node.js and JavaScript

2.3 SQLite database introduction

3 System Analysis

3.1 Feasibility analysis

3.1.1 Economic feasibility

3.1.2 Technical Feasibility

3.1.3 Operation Feasibility

3.2 Analysis of Performance Requirements

3.3 Design process analysis

4 system design

4.1 The overall design idea of ​​the system

4.2 Structural Diagram and Introduction of System Functional Modules

4.3 Database design

5 system function realization

5.1 Login interface

5.2 System main interface

5.3 Commodity list interface

5.4 Shopping cart interface

5.5 Personal center and modify data interface

6 APP testing

6.1 Program testing

6.2 Specific analysis of the test

6.3 Test conclusion

6.4 Follow-up Outlook of APP

in conclusion

references

7. Summary

In the implementation process of the fresh vegetable APP system, the most commonly used technologies are Java and JavaScript languages, the database is Android Studio with SQList database, and the server uses Node.js. After the test is completed and the corresponding deficiencies are modified, the Fresh Vegetable APP can run perfectly. After registering an account, the user returns to the login interface, and after logging into the APP, add the products he needs to the shopping cart, and then pay.

During the entire fresh vegetable APP development process, most of the content was completed by myself. When encountering problems, I asked my classmates for advice, and looked up relevant information and examples on the Internet. Finally, the design of Fresh Vegetable APP was completed, and many useful things were harvested during the whole development process.

Before that, I didn't have a deep understanding of the APP, so I encountered some difficulties at the beginning. For example, the shopping cart was the biggest problem faced in the entire development process. At the beginning of the implementation, I only completed the interface, but for adding Or there are many problems with the delete function. This problem is a big problem, which involves algorithms, interface interaction, etc., but it was finally solved through classmates and online information. After solving this biggest problem, I feel very happy in my heart, increase my self-confidence, and have the confidence to overcome difficulties when I encounter them in the future. In the process of completing the graduation project, I learned that what I learned in books is not enough. If you want to really engage in this industry, you must get started and put it into practice. Only after being tempered in practice can we truly understand the theory and truly master the knowledge in books. After the graduation project, I found that I learned not only professional knowledge, but also the method of combining practice and theory. In the whole design process, the attitude of never retreating when encountering difficulties is more important.

Guess you like

Origin blog.csdn.net/lf21qp/article/details/131469820