├── .gitignore ├── README.md ├── app.js ├── app.json ├── app.wxss ├── pages └── index │ ├── index.js │ ├── index.json │ ├── index.wxml │ └── index.wxss ├── project.config.json └── wxStar ├── wxStar.js ├── wxStar.wxml └── wxStar.wxss /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .DS_Store 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wxStar项目说明 2 | 3 | wxStar是在小程序中实现评分/评星效果,见效果图,也可以直接看代码 4 | 5 | ![Alt text](http://demos.pxuexiao.com/web_css/img/wxStar.gif) 6 | 7 | ## 使用说明 8 | 9 | ### wxml 10 | 11 | <import src="/wxStar/wxStar.wxml" /> 12 | 13 | <template is="wxStar" data="{{wxStar: wxStar}}" /> 14 | 15 | 16 | 17 | ### js 18 | 19 | // wxStar初始化 20 | 21 | wxStar.wxStar(this, 3, true); 22 | 23 | 参数说明: 24 | > this:当前Page对象 25 | 26 | 3:初始化星数 27 | 28 | true: 代码可编辑,即用户可以进行评星,如果是false,则表明只能查看,不可编辑 29 | 30 | 31 | 32 | ### wxss 33 | 34 | @import "/wxStar/wxStar.wxss"; 35 | 36 | 37 | 38 | 39 | ## 方法说明 40 | ### 回调方法 41 | this.starChangeCb();   // 选择星数后的callback 42 | 43 | this.initSuccessCb();     // 初始化完成后的callback 44 | 45 | ### 获取当前星数 46 | this.wxStarCont();   // 获取当前星数 47 | 48 | ### 重置当前星数 49 | this.wxStarInit(5);   // 重置星数 50 | 51 | ### 取消半星做法 52 | 在starChangeCb里面,重新调用wxStarInit方法即可~ 53 | 54 | 55 | 56 | ## 想添加技术讨论群,可以联系我 57 | ![Alt text](http://demos.pxuexiao.com/web_css/img/xigua_net.jpeg) 58 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | App({ 2 | onLaunch: function () { 3 | 4 | }, 5 | onShow: function(){ 6 | 7 | }, 8 | globalData: { 9 | 10 | }, 11 | }) -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages":[ 3 | "pages/index/index" 4 | ], 5 | "window":{ 6 | "backgroundColor":"#efeff4", 7 | "navigationBarBackgroundColor": "#00a8f3", 8 | "navigationBarTitleText": "wxStar 示例", 9 | "navigationBarTextStyle":"white" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lshxiao/wxStar/379f49acaeeb00bf5506bdd380f7f75540d34c7b/app.wxss -------------------------------------------------------------------------------- /pages/index/index.js: -------------------------------------------------------------------------------- 1 | var wxStar = require('../../wxStar/wxStar.js'); 2 | Page({ 3 | data: { 4 | }, 5 | onLoad: function (options) { 6 | // wxStar初始化 7 | wxStar.wxStar(this, 3, true); 8 | }, 9 | resetStar: function () { 10 | this.wxStarInit(0); 11 | }, 12 | alertStar: function () { 13 | var self = this; 14 | wx.showModal({ 15 | title: '提示', 16 | content: '当前选中' + self.wxStarCont() + '星', 17 | }) 18 | }, 19 | starChangeCb: function () { 20 | console.log('选择星之后的回调~'); 21 | } 22 | }) -------------------------------------------------------------------------------- /pages/index/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 |