测试类小程序:火爆朋友圈的左右脑测试实现
上周一款左右脑测试的小程序火爆朋友圈,本人也在第一时间做了一个仿制品,第一天上午提交,下午就审核通过,微信还是很给力的。最终发送到朋友圈的图片长下面这样:

用户整个使用流程如下:
1、用户扫描小程序码,进入关于测试的介绍页面:

2、点击开始,进入测试题目,总共9道测试题。

3、点击选择的选项,直接进入下一题。

4、选完最后一道题目,生成结果页面。

5、在结果页面,可以选择分享好友,直接把结果发送给好友,或者点击生成卡片,生成一张图片,保存到用户手机相册,用户可将图片发布朋友圈。生成的图片就是文章开头的那张图片。
整个流程就是这样。
下面,说说这个小程序的代码实现。
首先说下后端,后端我使用的是java。数据库就三张表,funtest_introduce测试介绍表,funtest_question测试题目表,funtest_result测试结果表。最终只提供一个接口给小程序端使用,接口数据如下:


aList数组里是9个测试题目,bList数组里是7种测试结果。
接着说小程序端,小程序端就三个页面,分别是测试介绍页面、题目页面、结果页面。
introduce.wxml测试介绍页面:

question.wxml题目页面:

每道题目的每个选项都有一个得分,把用户选择的选项得分加起来就是最后的总分。根据总分判断属于哪种结果区间,最后的结果页面就显示这个结果。
result.wxml测试结果页面:

最终生成的结果图片,不是实时生成的,而是预先就已经把图片准备好,因为最终结果只会是那7种中的一种。
准备的7张不同结果的图片:

其中的小程序码,需要后端生成一个固定的小程序码,调用的接口是https://mp.weixin.qq.com/debug/wxadoc/dev/api/qrcode.html 里面的接口A。
整个小程序实现流程就是这样。
小程序研究加入
