├── README.md ├── app.js ├── app.json ├── app.wxss ├── images ├── clock.png ├── home-logo.png ├── icon-a.png ├── icon-camera.png ├── icon-clock.png ├── icon-home-act.png ├── icon-home.png ├── icon-more.png ├── icon-my-act.png ├── icon-my.png ├── icon-q.png ├── icon-quiz-act.png ├── icon-quiz.png ├── msg-act.png ├── msg.png ├── question-empty.png └── welcome-txt.png ├── pages ├── home │ ├── home.js │ ├── home.json │ ├── home.wxml │ └── home.wxss ├── my │ ├── my.js │ ├── my.json │ ├── my.wxml │ └── my.wxss ├── question │ ├── question.js │ ├── question.json │ ├── question.wxml │ └── question.wxss ├── quiz │ ├── quiz.js │ ├── quiz.json │ ├── quiz.wxml │ └── quiz.wxss ├── replyMng │ ├── replyMng.js │ ├── replyMng.json │ ├── replyMng.wxml │ └── replyMng.wxss └── welcome │ ├── welcome.js │ ├── welcome.json │ ├── welcome.wxml │ └── welcome.wxss ├── utils ├── cfg.js └── util.js └── wxParse ├── emojis ├── 00.gif ├── 01.gif ├── 02.gif ├── 03.gif ├── 04.gif ├── 05.gif ├── 06.gif ├── 07.gif ├── 08.gif ├── 09.gif ├── 10.gif ├── 100.gif ├── 101.gif ├── 102.gif ├── 103.gif ├── 104.gif ├── 105.gif ├── 106.gif ├── 107.gif ├── 108.gif ├── 109.gif ├── 11.gif ├── 110.gif ├── 111.gif ├── 112.gif ├── 113.gif ├── 114.gif ├── 115.gif ├── 116.gif ├── 117.gif ├── 118.gif ├── 119.gif ├── 12.gif ├── 120.gif ├── 121.gif ├── 122.gif ├── 123.gif ├── 124.gif ├── 125.gif ├── 126.gif ├── 127.gif ├── 128.gif ├── 129.gif ├── 13.gif ├── 130.gif ├── 131.gif ├── 132.gif ├── 133.gif ├── 134.gif ├── 14.gif ├── 15.gif ├── 16.gif ├── 17.gif ├── 18.gif ├── 19.gif ├── 20.gif ├── 21.gif ├── 22.gif ├── 23.gif ├── 24.gif ├── 25.gif ├── 26.gif ├── 27.gif ├── 28.gif ├── 29.gif ├── 30.gif ├── 31.gif ├── 32.gif ├── 33.gif ├── 34.gif ├── 35.gif ├── 36.gif ├── 37.gif ├── 38.gif ├── 39.gif ├── 40.gif ├── 41.gif ├── 42.gif ├── 43.gif ├── 44.gif ├── 45.gif ├── 46.gif ├── 47.gif ├── 48.gif ├── 49.gif ├── 50.gif ├── 51.gif ├── 52.gif ├── 53.gif ├── 54.gif ├── 55.gif ├── 56.gif ├── 57.gif ├── 58.gif ├── 59.gif ├── 60.gif ├── 61.gif ├── 62.gif ├── 63.gif └── 64.gif ├── html2json.js ├── htmlparser.js ├── showdown.js ├── wxDiscode.js ├── wxParse.js ├── wxParse.wxml └── wxParse.wxss /README.md: -------------------------------------------------------------------------------- 1 | # UI快问 2 | 一个问答类微信小程序 3 | 4 | ###截图 5 | 6 | **首页** 7 | 8 | ![首页](http://ojk0a9sky.bkt.clouddn.com/wechatApp-home.jpg) 9 | 10 | **列表** 11 | 12 | ![列表](http://ojk0a9sky.bkt.clouddn.com/wechatApp-question.jpg) 13 | 14 | **表单** 15 | 16 | ![表单](http://ojk0a9sky.bkt.clouddn.com/wechatApp-quiz.jpg) 17 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | //app.js 2 | App({ 3 | onLaunch: function () { 4 | //调用API从本地缓存中获取数据 5 | var logs = wx.getStorageSync('logs') || [] 6 | logs.unshift(Date.now()) 7 | wx.setStorageSync('logs', logs) 8 | }, 9 | getUserInfo:function(cb){ 10 | var that = this 11 | if(this.globalData.userInfo){ 12 | typeof cb == "function" && cb(this.globalData.userInfo) 13 | }else{ 14 | //调用登录接口 15 | wx.login({ 16 | success: function () { 17 | wx.getUserInfo({ 18 | success: function (res) { 19 | that.globalData.userInfo = res.userInfo 20 | typeof cb == "function" && cb(that.globalData.userInfo) 21 | } 22 | }) 23 | } 24 | }) 25 | } 26 | }, 27 | globalData:{ 28 | userInfo:null 29 | } 30 | }) -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages":[ 3 | "pages/home/home", 4 | "pages/quiz/quiz", 5 | "pages/replyMng/replyMng", 6 | 7 | "pages/my/my", 8 | "pages/question/question", 9 | "pages/welcome/welcome" 10 | ], 11 | "tabBar": { 12 | "color":"#afb2b9", 13 | "backgroundColor":"#fff", 14 | "selectedColor":"#18b7ee", 15 | "borderStyle":"white", 16 | "list": [{ 17 | "pagePath": "pages/home/home", 18 | "text": "首页", 19 | "iconPath":"images/icon-home.png", 20 | "selectedIconPath":"images/icon-home-act.png" 21 | }, { 22 | "pagePath": "pages/quiz/quiz", 23 | "text": "提问", 24 | "iconPath":"images/icon-quiz.png", 25 | "selectedIconPath":"images/icon-quiz-act.png" 26 | }, { 27 | "pagePath": "pages/my/my", 28 | "text": "我的", 29 | "iconPath":"images/icon-my.png", 30 | "selectedIconPath":"images/icon-my-act.png" 31 | }] 32 | }, 33 | "window":{ 34 | "backgroundTextStyle":"light", 35 | "navigationBarBackgroundColor": "#18b7ee", 36 | "navigationBarTitleText": "UI快问", 37 | "navigationBarTextStyle":"white" 38 | } 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- 1 | /**app.wxss**/ 2 | page{ 3 | min-height: 100%; 4 | background-color: #f6f7fe; 5 | } 6 | .loading{ 7 | display: block; 8 | text-align: center; 9 | padding-top:50%; 10 | } 11 | -------------------------------------------------------------------------------- /images/clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/clock.png -------------------------------------------------------------------------------- /images/home-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/home-logo.png -------------------------------------------------------------------------------- /images/icon-a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/icon-a.png -------------------------------------------------------------------------------- /images/icon-camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/icon-camera.png -------------------------------------------------------------------------------- /images/icon-clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/icon-clock.png -------------------------------------------------------------------------------- /images/icon-home-act.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/icon-home-act.png -------------------------------------------------------------------------------- /images/icon-home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/icon-home.png -------------------------------------------------------------------------------- /images/icon-more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/icon-more.png -------------------------------------------------------------------------------- /images/icon-my-act.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/icon-my-act.png -------------------------------------------------------------------------------- /images/icon-my.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/icon-my.png -------------------------------------------------------------------------------- /images/icon-q.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/icon-q.png -------------------------------------------------------------------------------- /images/icon-quiz-act.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/icon-quiz-act.png -------------------------------------------------------------------------------- /images/icon-quiz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/icon-quiz.png -------------------------------------------------------------------------------- /images/msg-act.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/msg-act.png -------------------------------------------------------------------------------- /images/msg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/msg.png -------------------------------------------------------------------------------- /images/question-empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/question-empty.png -------------------------------------------------------------------------------- /images/welcome-txt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justyeh/UI-question/96f6744652b550740b241ee506a0865b51cae5e6/images/welcome-txt.png -------------------------------------------------------------------------------- /pages/home/home.js: -------------------------------------------------------------------------------- 1 | // pages/index/index.js 2 | var cgf = require('../../utils/cfg') 3 | Page({ 4 | data: { 5 | hasQuestion: false, 6 | hasNewMsg: { 7 | question: false, 8 | ask: true 9 | } 10 | }, 11 | //页面加载 12 | onLoad: function(options) { 13 | 14 | /*var slideDots = []; 15 | this.data.imgUrls.forEach((item,index)=>{ 16 | var flag = index === 0 ? true : false; 17 | slideDots.push({ 18 | act: flag 19 | }); 20 | }) 21 | this.setData({ 22 | swiper:cgf.swiperCfg, 23 | slideDots 24 | }) 25 | 26 | var self = this; 27 | this.setData({ 28 | welcomeImg:'https://img6.bdstatic.com/img/image/pcindex/PC112.jpg' 29 | }); 30 | wx.getSystemInfo({ 31 | success: function(res) { 32 | self.setData({ 33 | windowHeight:res.windowHeight 34 | }) 35 | } 36 | });*/ 37 | }, 38 | //渲染完成 39 | onReady: function() { 40 | /*var animation = wx.createAnimation({ 41 | duration: 500, 42 | delay:2000, 43 | timingFunction: 'ease' 44 | }) 45 | animation.opacity(0).step(); 46 | this.setData({ 47 | fadeOut:animation, 48 | }) 49 | setTimeout(function(){ 50 | this.setData({ 51 | isWelcome:false 52 | //更改颜色navigationBarBackgroundColor:#65b1ec 53 | }) 54 | }.bind(this),2500);*/ 55 | 56 | }, 57 | //修复自带swiper组件不能设置dot颜色的bug 58 | swiperChange: function(event) { 59 | var slideDots = this.data.slideDots; 60 | slideDots.forEach((item, index) => { 61 | item.act = event.detail.current === index ? true : false 62 | }) 63 | this.setData({ 64 | slideDots 65 | }) 66 | } 67 | }) -------------------------------------------------------------------------------- /pages/home/home.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/home/home.wxml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 15 11 | 提问 12 | 13 | 14 | 15 15 | 回复 16 | 17 | 18 | 19 | 20 | 21 | 22 | 您还没有提问 23 | 24 | 25 | 26 | 27 | 您还没有提问 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /pages/home/home.wxss: -------------------------------------------------------------------------------- 1 | /* pages/index/index.wxss */ 2 | page{ 3 | display: block; 4 | min-height: 100%; 5 | background-color: #f3f3f3; 6 | } 7 | .banner{ 8 | height: 615rpx; 9 | background: #18b7ee; 10 | text-align: center; 11 | } 12 | .banner image{ 13 | width: 310rpx; 14 | margin: 130rpx 0; 15 | } 16 | .banner navigator{ 17 | background: #ffffff; 18 | color: #18b7ee; 19 | display: block; 20 | width: 690rpx; 21 | height: 90rpx; 22 | line-height: 90rpx; 23 | margin: 0 auto; 24 | border-radius: 45px; 25 | } 26 | .main{ 27 | display: flex; 28 | background: #ffffff; 29 | padding: 35rpx; 30 | justify-content: space-between; 31 | } 32 | .main navigator{ 33 | width: 330rpx; 34 | height: 160rpx; 35 | text-align: center; 36 | border-radius: 20rpx; 37 | background: #f7f9f9; 38 | } 39 | .main navigator .num{ 40 | color: #18b7ee; 41 | font-size: 48rpx; 42 | line-height: 48rpx; 43 | display: block; 44 | padding: 30rpx 0 15rpx 0; 45 | } 46 | .main navigator .text{ 47 | color: #666; 48 | font-size: 13px; 49 | position: relative; 50 | line-height: 13px; 51 | } 52 | .main navigator.act .text:after{ 53 | content: ''; 54 | position: absolute; 55 | right: -10px; 56 | top:0; 57 | bottom: 2px; 58 | margin: auto; 59 | width: 8px; 60 | height: 8px; 61 | border-radius: 8px; 62 | background: #f35000; 63 | } 64 | .main-empty{ 65 | display: flex; 66 | justify-content: center; 67 | align-items: center; 68 | padding: 90rpx 0; 69 | } 70 | .main-empty image{ 71 | width: 45rpx; 72 | margin-right: 20rpx; 73 | } 74 | .main-empty text{ 75 | color: #cacccf; 76 | font-size: 14px; 77 | font-weight: 500; 78 | } -------------------------------------------------------------------------------- /pages/my/my.js: -------------------------------------------------------------------------------- 1 | var cfg = require('../../utils/cfg'); 2 | 3 | Page({ 4 | data: { 5 | isLoading: true, 6 | questionList: [] 7 | }, 8 | goDetail: function(event) { 9 | wx.navigateTo({ 10 | url: '/pages/replyMng/replyMng' 11 | }) 12 | }, 13 | onLoad: function(options) { 14 | /*wx.setNavigationBarTitle({ 15 | title: options.type === 'question' ? '我的提问' : '我的回复', 16 | })*/ 17 | var _self = this; 18 | wx.request({ 19 | url: cfg.api.host + 'topics', 20 | header: { 21 | 'content-type': 'application/json' 22 | }, 23 | success: function(res) { 24 | //console.log(res) 25 | _self.setData({ 26 | isLoading: false, 27 | questionList: res.data.data 28 | }) 29 | } 30 | }); 31 | } 32 | }) -------------------------------------------------------------------------------- /pages/my/my.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "我的问题" 3 | } -------------------------------------------------------------------------------- /pages/my/my.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | loading 4 | 5 | 6 | 7 | 8 | {{data.title}} 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | {{data.create_at}} 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /pages/my/my.wxss: -------------------------------------------------------------------------------- 1 | 2 | .block{ 3 | background: #fff; 4 | padding: 0 30rpx; 5 | margin-bottom: 30rpx; 6 | } 7 | .block .content{ 8 | color: #000; 9 | font-size: 34rpx; 10 | line-height: 50rpx; 11 | padding: 30rpx 0; 12 | border-bottom: solid 1px #e7ecee; 13 | } 14 | .block .info{ 15 | height: 70rpx; 16 | display: flex; 17 | justify-content: flex-end; 18 | align-items: center; 19 | position: relative; 20 | } 21 | 22 | .block .info image{ 23 | width: 16px; 24 | } 25 | 26 | .block .info text{ 27 | color: #999; 28 | font-size: 26rpx; 29 | padding-left: 20rpx; 30 | } 31 | .block .msg{ 32 | position: absolute; 33 | left:30rpx; 34 | top: 4rpx; 35 | bottom: 0; 36 | margin: auto; 37 | } 38 | 39 | 40 | -------------------------------------------------------------------------------- /pages/question/question.js: -------------------------------------------------------------------------------- 1 | // pages/question/question.js 2 | Page({ 3 | data:{}, 4 | onLoad:function(options){ 5 | // 页面初始化 options为页面跳转所带来的参数 6 | }, 7 | onReady:function(){ 8 | // 页面渲染完成 9 | }, 10 | onShow:function(){ 11 | // 页面显示 12 | }, 13 | onHide:function(){ 14 | // 页面隐藏 15 | }, 16 | onUnload:function(){ 17 | // 页面关闭 18 | } 19 | }) -------------------------------------------------------------------------------- /pages/question/question.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/question/question.wxml: -------------------------------------------------------------------------------- 1 | 2 | pages/question/question.wxml 3 | -------------------------------------------------------------------------------- /pages/question/question.wxss: -------------------------------------------------------------------------------- 1 | /* pages/question/question.wxss */ -------------------------------------------------------------------------------- /pages/quiz/quiz.js: -------------------------------------------------------------------------------- 1 | var logData = []; 2 | 3 | Page({ 4 | data: { 5 | restNum: 200, 6 | imgs: [] 7 | }, 8 | handleTextareaInput: function(e) { 9 | this.setData({ 10 | restNum: 200 - e.detail.value.length 11 | }); 12 | }, 13 | uploadFile: function() { 14 | var _this = this; 15 | wx.showActionSheet({ 16 | itemList: ['从相册中选择', '拍照'], 17 | itemColor: "#18b7ee", 18 | success: function(res) { 19 | if (!res.cancel) { 20 | if (res.tapIndex == 0) { 21 | _this.chooseWxImage('album') 22 | } else if (res.tapIndex == 1) { 23 | _this.chooseWxImage('camera') 24 | } 25 | } 26 | } 27 | }) 28 | }, 29 | chooseWxImage: function(type) { 30 | var _this = this; 31 | wx.chooseImage({ 32 | count: 1, // 默认9 33 | sizeType: ['original', 'compressed'], 34 | sourceType: [type], 35 | success: function(res) { 36 | var imgsArr = _this.data.imgs; 37 | imgsArr.push(res.tempFilePaths[0]); 38 | 39 | _this.setData({ 40 | imgs: imgsArr 41 | }) 42 | } 43 | }) 44 | }, 45 | handleFormSubmit: function() { 46 | if (this.data.restNum == 200) { 47 | wx.showToast({ 48 | title: '请填写内容', 49 | icon: 'success', 50 | duration: 2000 51 | }) 52 | return 53 | } 54 | wx.showModal({ 55 | title: '提示', 56 | content: '是否提交您的问题', 57 | cancelColor:"#666", 58 | confirmColor:'#17b6ed', 59 | duration: 2000, 60 | success: function() { 61 | //提交表单 62 | var formData = { 63 | uid: util.getUserID(), 64 | user_name: e.detail.value.nick_name, 65 | baby_sex: e.detail.value.baby_sex, 66 | baby_age: e.detail.value.baby_age 67 | } 68 | console.log(formData) 69 | app.apiFunc.upload_file(app.apiUrl.modify_user, this.data.logo, 'photos', formData, 70 | function(res) { 71 | console.log(res); 72 | }, 73 | function() {}) 74 | } 75 | }); 76 | }, 77 | upload_file: function(url, filePath, name, formData, success, fail) { 78 | console.log('a=' + filePath) 79 | wx.uploadFile({ 80 | url: rootUrl + url, 81 | filePath: filePath, 82 | name: name, 83 | header: { 84 | 'content-type': 'multipart/form-data' 85 | }, // 设置请求的 header 86 | formData: formData, // HTTP 请求中其他额外的 form data 87 | success: function(res) { 88 | console.log(res); 89 | if (res.statusCode == 200 && !res.data.result_code) { 90 | typeof success == "function" && success(res.data); 91 | } else { 92 | typeof fail == "function" && fail(res); 93 | } 94 | }, 95 | fail: function(res) { 96 | console.log(res); 97 | typeof fail == "function" && fail(res); 98 | } 99 | }) 100 | } 101 | }); -------------------------------------------------------------------------------- /pages/quiz/quiz.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "问" 3 | } -------------------------------------------------------------------------------- /pages/quiz/quiz.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 请在此输入您的问题: 4 | 5 |
6 | 7 |