CN108536442A - 一种基于微信小程序平台左右结构层级展示及快速加载的药品分类方法 - Google Patents

一种基于微信小程序平台左右结构层级展示及快速加载的药品分类方法 Download PDF

Info

Publication number
CN108536442A
CN108536442A CN201810327251.9A CN201810327251A CN108536442A CN 108536442 A CN108536442 A CN 108536442A CN 201810327251 A CN201810327251 A CN 201810327251A CN 108536442 A CN108536442 A CN 108536442A
Authority
CN
China
Prior art keywords
classify
view
data
files
small routine
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201810327251.9A
Other languages
English (en)
Inventor
陈林
张来卿
庞严冬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhuhai Hengqin Shengda Zhaoye Technology Investment Co Ltd
Original Assignee
Zhuhai Hengqin Shengda Zhaoye Technology Investment Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhuhai Hengqin Shengda Zhaoye Technology Investment Co Ltd filed Critical Zhuhai Hengqin Shengda Zhaoye Technology Investment Co Ltd
Priority to CN201810327251.9A priority Critical patent/CN108536442A/zh
Publication of CN108536442A publication Critical patent/CN108536442A/zh
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0481Interaction techniques based on graphical user interfaces [GUI] based on specific properties of the displayed interaction object or a metaphor-based environment, e.g. interaction with desktop elements like windows or icons, or assisted by a cursor's changing behaviour or appearance
    • G06F3/0482Interaction with lists of selectable items, e.g. menus

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明涉及微信小程序平台技术领域,特别涉及一种基于微信小程序平台左右结构层级展示的药品分类。本发明的方法是在用户进入左右结构的分类页面时立即通过httpGet方法读取远程服务器上的别数据,并把其缓存到本地中,如果用户再次进入时,只需要读取本地缓存数据即可。缓存后把获得的父类数据绑定到左边的view上并进行遍历,并给左侧的子view绑定changeRightTab事件;然后在changeRightTab方法实现根据左侧点击的索引及id来获得子分类数据,并把其绑定到右侧View,从而实现简洁、快速地分类展示。本发明解决了在微信小程序里药品分类展示缓慢及零乱的问题。

Description

一种基于微信小程序平台左右结构层级展示及快速加载的药 品分类方法
技术领域
本发明涉及微信小程序平台技术领域,特别涉及一种基于微信小程序平台左右结构层级展示及快速加载的药品分类方法。
背景技术
在微信小程序平台上访问某些药品小程序时,没有那种简洁、细致及全面的分类展示页面;为了解决这些问题,需要实现一种左右结构层级展示的药品分类方法来方便客户浏览。
发明内容
本发明解决的技术问题在于提供一种基于微信小程序平台左右结构层级展示及快速加载药品的分类方法;解决了在微信小程序里药品分类展示零乱及加载缓慢的问题。
本发明解决上述技术问题的技术方案是:
在项目里创建一个classify包及4个文件,分别为classify.js、classify.json、classify.wxml、classify.wxss; 然后在classify.wxml文件里绘制出药品分类的界面,为左右结构,左边view为主目录,右边view为明细,在classify.wxss文件里调节样式; 接着在classify.js中的data时定义parentDisplay、childDisplay是否显示变量,navLeftItems、curRightItems类别列表变量及curNav、curIndex索引变量;在classify.js文件中的onload方法里通过httpGet方法读取远程服务器上的类别数据,如加载成功,给上面的变量设置不同状态的值。把获得的值绑定到classify.wxml文件中的左右view上并进行遍历,给左侧的子view绑定事件changeRightTab;最后实现changeRightTab方法,根据左侧点击的索引及id来展示右侧不同的药品子类别信息;从而解决了在微信小程序里药品分类展示零乱及加载缓慢的问题。
所述的方法具体包括如下步骤:
步骤一、在项目里创建一个classify包及4个文件,分别为classify.js、classify.json、classify.wxml、classify.wxss;
步骤二、在classify.wxml文件里绘制出药品分类的界面,为左右结构,左边view为主目录,右边view为明细,在classify.wxss文件里调节样式;
步骤三、在classify.js中的data时定义parentDisplay、childDisplay是否显示变量,navLeftItems、curRightItems类别列表变量及curNav、curIndex索引变量;
步骤四、在classify.js文件中的onload方法里通过httpGet方法读取远程服务器上的类别数据,如加载成功,把数据缓存到本地,并把值赋给上面的变量。如果用户再次进入,直接读取缓存数据;
步骤五、给classify.wxml文件中的左view绑定navLeftItems并进行遍历,并同时绑定事件changeRightTab;
步骤六、实现changeRightTab方法,根据左侧点击的索引及id来展示右侧不同的药品子类别信息。
本发明的有益效果:在项目里创建一个classify包及4个文件,分别为classify.js、classify.json、classify.wxml、classify.wxss; 然后在classify.wxml文件里绘制出药品分类的界面,为左右结构,左边view为主目录,右边view为明细,在classify.wxss文件里调节样式; 接着在classify.js中的data时定义parentDisplay、childDisplay是否显示变量,navLeftItems、curRightItems类别列表变量及curNav、curIndex索引变量;在classify.js文件中的onload方法里通过httpGet方法读取远程服务器上的类别数据,如加载成功,给上面的变量设置不同状态的值。把获得的值绑定到classify.wxml文件中的左右view上并进行遍历,给左侧的子view绑定事件changeRightTab;最后实现changeRightTab方法,根据左侧点击的索引及id来展示右侧不同的药品子类别信息,从而达到简洁、细致、全面快速地在小程序中把药品分类展示的目的。有效解决了在微信小程序里药品分类展示零乱及加载缓慢的问题。
附图说明
下面结合附图对本发明进一步说明:
图1为本发明的流程图。
图2为本发明的展示图。
具体实施方式
如图1所示,本发明采用如下步骤:
步骤一、在项目里创建一个classify包及4个文件,分别为classify.js、classify.json、classify.wxml、classify.wxss;
步骤二、在classify.wxml文件里绘制出药品分类的界面,为左右结构,左边view为主目录,右边view为明细,在classify.wxss文件里调节样式;如:
<view class="nav_left" style="display:{{parentDisplay}}">
</view>
<view class="nav_right" style="display:{{childDisplay}}">
</view>
步骤三、在classify.js中的data时定义parentDisplay、childDisplay是否显示变量,navLeftItems、curRightItems类别列表变量及curNav、curIndex索引变量:
data: {
parentDisplay:'',
childDisplay:'',
navLeftItems: [],
curNav: 1,
curIndex: 0,
curRightItems:[]
},
步骤四、在classify.js文件中的onload方法里通过httpGet方法读取远程服务器上的类别数据,如加载成功,把数据缓存到本地,并把值赋给上面的变量。如果用户再次进入,直接读取缓存数据;如:
onLoad: function (options) {
this.setData({ options: options })
this.listCategory();
},
/**加载购物车数据,计算数量*/
listCategory: function () {
var categories = ws.getStoreage(“categories”);
if(categories && categories.length > 0){
//设置变量……
}else{
var that = this;
httpUtil.httpGet(api.getCategoryUrl, { }, function (res) {
var datas = res.data;
if (datas.length > 0) {
wx.setStorage({“categories”}, datas);
that.setData({
parentDisplay: '',
childDisplay: '',
navLeftItems: datas,
curRightItems: datas[0].ProductCategoryChildList
})
} else {
that.setData({
parentDisplay: 'none',
childDisplay: 'none',
emptyDisplay: ''
})
}
}
});
步骤五、给classify.wxml文件中的左view绑定navLeftItems并进行遍历,并同时绑定事件changeRightTab;如:
<view class="nav_left" style="display:{{parentDisplay}}">
<block wx:for="{{navLeftItems}}" wx:key="{{index}}">
<view class="nav_left_items {{curNav == item.ProductCategoryID 'active' : ''}}" bindtap="changeRightTab" data-index="{{index}}" data-id="{{item.ProductCategoryID}}">{{item.CategoryName}}</view>
</block>
</view>
<view class="nav_right" style="display:{{childDisplay}}">
<block wx:for="{{curRightItems}}" wx:key="{{index}}">
<view class="nav_right_items">
<navigator url="../search/search ProductCategoryID={{item.ProductCategoryID}}">
<view> <text>{{item.CategoryName}}</text> </view>
</navigator>
</view>
</block>
</view>
</view>
步骤六、实现changeRightTab方法,根据左侧点击的索引及id来展示右侧不同的药品子类别信息。如:
changeRightTab: function (e) {
var id = e.target.dataset.id;
var index = parseInt(e.target.dataset.index);
this.setData({
curNav: id,
curIndex: index,
curRightItems: this.data.navLeftItems[index].ProductCategoryChildList
})
}。

Claims (2)

1.一种基于微信小程序平台左右结构层级展示及快速加载的药品分类方法,其特征在于:首先在项目里创建一个classify包及4个文件,分别为classify.js、classify.json、classify.wxml、classify.wxss, 并在classify.wxml文件里绘制出左右结构的药品分类的界面,左边view为主目录,右边view为明细;当用户进入分类页面时立即通过httpGet方法读取远程服务器上的别数据,并把其缓存到本地中,如果用户再次进入时,只需要读取本地缓存数据即可;缓存后把获得的父类数据绑定到左边的view上并进行遍历,并给左侧的子view绑定changeRightTab事件;然后在changeRightTab方法实现根据左侧点击的索引及id来获得子分类数据,并把其绑定到右侧View,实现简洁、快速地分类展示;从而解决了在微信小程序里药品分类展示零乱及加载缓慢的问题。
2.根据权利要求1所述的解决了在微信小程序里药品分类展示零乱及加载缓慢的方法,其特征在于:所述的方法具体包括如下步骤:
步骤一、在项目里创建一个classify包及4个文件,分别为classify.js、classify.json、classify.wxml、classify.wxss;
步骤二、在classify.wxml文件里绘制出药品分类的界面,为左右结构,左边view为主目录,右边view为明细,在classify.wxss文件里调节样式;
步骤三、在classify.js中的data时定义parentDisplay、childDisplay是否显示变量,navLeftItems、curRightItems类别列表变量及curNav、curIndex索引变量;
步骤四、在classify.js文件中的onload方法里通过httpGet方法读取远程服务器上的类别数据,如加载成功,把数据缓存到本地,并把值赋给上面的变量;如果用户再次进入,直接读取缓存数据;
步骤五、给classify.wxml文件中的左view绑定navLeftItems并进行遍历,并同时绑定事件changeRightTab;
步骤六、实现changeRightTab方法,根据左侧点击的索引及id来展示右侧不同的药品子类别信息。
CN201810327251.9A 2018-04-12 2018-04-12 一种基于微信小程序平台左右结构层级展示及快速加载的药品分类方法 Pending CN108536442A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810327251.9A CN108536442A (zh) 2018-04-12 2018-04-12 一种基于微信小程序平台左右结构层级展示及快速加载的药品分类方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810327251.9A CN108536442A (zh) 2018-04-12 2018-04-12 一种基于微信小程序平台左右结构层级展示及快速加载的药品分类方法

Publications (1)

Publication Number Publication Date
CN108536442A true CN108536442A (zh) 2018-09-14

Family

ID=63481062

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810327251.9A Pending CN108536442A (zh) 2018-04-12 2018-04-12 一种基于微信小程序平台左右结构层级展示及快速加载的药品分类方法

Country Status (1)

Country Link
CN (1) CN108536442A (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110502235A (zh) * 2019-07-24 2019-11-26 江苏大学 一种基于微信小程序和活动的展示方法

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9582301B2 (en) * 2014-09-17 2017-02-28 International Business Machines Corporation Method of defining javascript objects
CN106980504A (zh) * 2017-03-28 2017-07-25 腾讯科技(深圳)有限公司 一种应用程序开发方法及其工具、设备

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9582301B2 (en) * 2014-09-17 2017-02-28 International Business Machines Corporation Method of defining javascript objects
CN106980504A (zh) * 2017-03-28 2017-07-25 腾讯科技(深圳)有限公司 一种应用程序开发方法及其工具、设备

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ITDRAGON龙: "微信小程序入门六本地缓存和搜索", 《HTTPS://BLOG.CSDN.NET/QQ_19558705/ARTICLE/DETAILS/61424108》 *
MICHAEL_OUYANG: "微信小程序之侧栏分类——微信小程序实战商城系列", 《HTTPS://BLOG.CSDN.NET/MICHAEL_OUYANG/ARTICLE/DETAILS/70172207》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110502235A (zh) * 2019-07-24 2019-11-26 江苏大学 一种基于微信小程序和活动的展示方法

Similar Documents

Publication Publication Date Title
CN105117474B (zh) 在网页的阅读模式中进行推荐信息加载的方法和装置
KR102278657B1 (ko) 웹 페이지에 대한 컨텐츠 아이템에 대한 사이즈 자동 결정
CN103034517B (zh) 浏览器控制工具加载方法和装置
CN105378726B (zh) 利用更新层的数据库分区
CN103348342B (zh) 基于用户话题简档的个人内容流
US8935620B1 (en) Dynamic content management
US7953777B2 (en) Method and system for retrieving and organizing web media
CN106415537B (zh) 将本地应用搜索结果插入到web搜索结果中
CN104077387B (zh) 一种网页内容显示方法和浏览器装置
US9773073B1 (en) Online information system with continuous scrolling and position correction
US8745161B2 (en) Determining and displaying a count of unread items in content feeds
JP5786105B2 (ja) 情報処理装置、情報処理方法、情報処理プログラム、表示制御装置、および表示制御プログラム
US20130227484A1 (en) Customizing a tag cloud
CN110245069B (zh) 页面版本的测试方法和装置、页面的展示方法和装置
US9934202B1 (en) Managing paginated data
WO2012058408A2 (en) Social networking relevance index
CN104052809B (zh) 一种网站测试的分流控制方法和装置
JP2011525659A (ja) Webページ対話に基づく広告提示
US8103967B2 (en) Generating and organizing references to online content
US9741018B2 (en) Systems and methods for extracting similar group elements
CN103034518A (zh) 加载浏览器控制工具的方法及浏览器
US20130227391A1 (en) Method and apparatus for displaying webpage
US11074646B1 (en) Dynamically selecting an image for display
CN106557556A (zh) 一种网页页面的展示方法、装置、服务器和系统
CN108536442A (zh) 一种基于微信小程序平台左右结构层级展示及快速加载的药品分类方法

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20180914

WD01 Invention patent application deemed withdrawn after publication