detail.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. import common from '../../utils/util';
  2. import server from '../../utils/main';
  3. const app = getApp();
  4. var times = 1;
  5. var pageIndex = 0;
  6. var QuestionItem = [];
  7. var tempAnswerList = [];
  8. var arrAnswerID = [];
  9. var isAndroid = false;
  10. const waitTime = ["", "10秒钟", "15秒钟", "20秒钟", "25秒钟"];
  11. Page({
  12. data: {
  13. version: app.globalData.Version,
  14. IsShowMenu: false,
  15. filter: 'horizontal',
  16. //filter: 'vertical',
  17. PageNumber: 1,
  18. PageCount: 60,
  19. IsFinished: false,
  20. arrPage: [],
  21. ShowLoading: false,
  22. IsDistabled: "",
  23. NameClass: "",
  24. AddDisabled: "",
  25. SubDisabled: "btnAddSubDisabled",
  26. HelpHidden7: true,
  27. HelpHidden3: true,
  28. HelpHidden8: true,
  29. ShowAndroidNotice: false,
  30. },
  31. onLoad: function (options) {
  32. var that = this;
  33. var id = options.id;
  34. isAndroid = false;
  35. if (app.globalData.systemInfo.system && app.globalData.systemInfo.system.indexOf("Android") >= 0)
  36. isAndroid = true;
  37. this.setData({
  38. Containnerheight: server.getWindowHeight(),
  39. ID: id,
  40. ShowAndroidNotice: isAndroid,
  41. });
  42. var systemInfo = wx.getSystemInfoSync();
  43. if (systemInfo.system && systemInfo.system.indexOf("Android") >= 0) {
  44. times = 2;
  45. }
  46. this.getDetail(id);
  47. if (id > 0) {
  48. common.getStorageValue(this, "HelpHidden3", false, function () {
  49. that.showHelp();
  50. });
  51. } else {
  52. common.getStorageValue(this, "HelpHidden8", false, function () {
  53. that.showHelp8();
  54. });
  55. }
  56. common.getStorageValue(this, "IsShare", 0, function () {
  57. if (that.data.IsShare == 0 &&
  58. app.globalData.userInfo.IsMember == 0 &&
  59. app.globalData.userInfo.IsShow == 1 &&
  60. app.globalData.IsLocked == 1
  61. ) {
  62. wx.navigateTo({
  63. url: '../../package4/main/share',
  64. })
  65. }
  66. });
  67. },
  68. onShow: function () {
  69. if (this.data.ID == -1)
  70. this.getDetail(this.data.ID);
  71. },
  72. onUnload: function () {
  73. wx.hideLoading();
  74. this.closeHelp();
  75. },
  76. getDetail: function (id) {
  77. var item = {};
  78. if (id > 0) {
  79. var data = wx.getStorageSync('QuestionTypeList');
  80. for (var i = 0; i < data.length; i++) {
  81. for (var k = 0; k < data[i].List.length; k++) {
  82. if (id == data[i].List[k].ID) {
  83. item = data[i].List[k];
  84. item.Example[0] = item.Example[0].replace("+", " + ").replace("-", " - ").replace("×", " × ").replace("÷", " ÷ ");
  85. if (item.Example[1])
  86. item.Example[1] = item.Example[1].replace("+", " + ").replace("-", " - ").replace("×", " × ").replace("÷", " ÷ ");
  87. item.IconName = app.globalData.fileUrl + item.IconName;
  88. if (item.Name.length > 12)
  89. item.NameClass = "text2";
  90. break;
  91. }
  92. }
  93. }
  94. } else {
  95. item.Name = "我的错题集";
  96. var list = wx.getStorageSync('ErrorList');
  97. item.ErrorList = list;
  98. }
  99. this.setData({
  100. QuestionTypeItem: item,
  101. });
  102. //有竖式则缺省竖式
  103. if (item.QuestionNumber3 > 0) {
  104. this.menuClick({
  105. currentTarget: {
  106. dataset: {
  107. id: "vertical"
  108. }
  109. }
  110. })
  111. }
  112. },
  113. gotoError: function (e) {
  114. wx.navigateTo({
  115. url: '../main/errorlist',
  116. });
  117. },
  118. gotoAnswer: function (e) {
  119. wx.navigateTo({
  120. url: '../main/answer',
  121. });
  122. this.closeHelp2();
  123. },
  124. getFinish: function () {
  125. server.playSound("/sounds/click.mp3");
  126. this.setData({
  127. ShowLoading: true,
  128. BtnText: "全部保存到相册",
  129. });
  130. wx.hideLoading();
  131. arrAnswerID = [];
  132. tempAnswerList = [];
  133. this.getAnswerID();
  134. if (this.data.ID > 0) {
  135. this.getList(this.data.ID);
  136. } else {
  137. this.getErrorList();
  138. }
  139. this.closeHelp();
  140. },
  141. //重新生成试卷
  142. ResetFinish: function () {
  143. var that = this;
  144. wx.showLoading({
  145. title: "正在重置",
  146. complete: function () {
  147. var list = that.data.arrPage;
  148. for (var i = 0; i < list.length; i++) {
  149. wx.removeSavedFile({
  150. filePath: list[i].TempImagePath
  151. });
  152. }
  153. that.setData({
  154. arrPage: [],
  155. PageNumber: 1,
  156. });
  157. var tempList = wx.getStorageSync("AnswerList");
  158. for (var i = 0; i < list.length; i++) {
  159. tempList.shift();
  160. }
  161. wx.setStorageSync("AnswerList", tempList);
  162. wx.hideLoading();
  163. that.getFinish();
  164. }
  165. });
  166. },
  167. //题卡数据列表
  168. getList: function (id) {
  169. var that = this;
  170. var pageNum = that.data.PageNumber;
  171. var QuestionTypeCategory = 3;
  172. if (that.data.filter == "horizontal")
  173. QuestionTypeCategory = 2;
  174. pageIndex = 0;
  175. server.getData('GetQuestionTypesPrint?ID=' + id + '&QuestionTypeCategory=' + QuestionTypeCategory + '&PageNum=' + pageNum, function (data) {
  176. //console.log("UserInfo:" + data);
  177. if (data) {
  178. that.setData({
  179. IsFinished: true,
  180. arrPage: [],
  181. IsDistabled: "",
  182. WaitTime: waitTime[that.data.PageNumber],
  183. });
  184. QuestionItem = data;
  185. QuestionItem.IconName = that.data.QuestionTypeItem.IconName;
  186. // if (isAndroid) {
  187. // console.log("android");
  188. // const query = wx.createSelectorQuery();
  189. // query.select('#Canvas')
  190. // .fields({ node: true, size: true })
  191. // .exec((res) => {
  192. // const canvas = res[0].node;
  193. // const ctx = canvas.getContext('2d');
  194. // canvas.width = 1050;
  195. // canvas.height = 1485;
  196. // wx.canvasToTempFilePath({
  197. // x: 0,
  198. // y: 0,
  199. // width: canvas.width,
  200. // height: canvas.height,
  201. // canvas: canvas,
  202. // success: function(res2) {
  203. // that.saveImage();
  204. // }
  205. // });
  206. // });
  207. // }
  208. // else {
  209. that.saveImage();
  210. // }
  211. }
  212. });
  213. },
  214. //错题列表
  215. getErrorList: function () {
  216. var that = this;
  217. QuestionItem = that.data.QuestionTypeItem;
  218. if (QuestionItem.ErrorList.length > 0) {
  219. QuestionItem.Category = -1; //错题集类别
  220. QuestionItem.QuestionTypeCategory = 2;
  221. QuestionItem.CategoryName = "";
  222. QuestionItem.Name = "我的错题集";
  223. QuestionItem.QuestionTypeLevel = "";
  224. QuestionItem.PageCount = QuestionItem.ErrorList.length > 60 ? 60 : QuestionItem.ErrorList.length;
  225. QuestionItem.QuestionList = QuestionItem.ErrorList;
  226. QuestionItem.CreateTime = common.formatDateCHSLong(new Date());
  227. QuestionItem.IconName = app.globalData.fileUrl + "questioncard_icon_grade0102_size01.png";
  228. QuestionItem.QuestionList = common.randomArray(QuestionItem.QuestionList);
  229. delete QuestionItem.ErrorList;
  230. pageIndex = 0;
  231. that.setData({
  232. IsFinished: true,
  233. arrPage: [],
  234. IsDistabled: "",
  235. WaitTime: waitTime[that.data.PageNumber],
  236. });
  237. // if (isAndroid) {
  238. // console.log("android");
  239. // const query = wx.createSelectorQuery();
  240. // query.select('#Canvas')
  241. // .fields({ node: true, size: true })
  242. // .exec((res) => {
  243. // const canvas = res[0].node;
  244. // const ctx = canvas.getContext('2d');
  245. // canvas.width = 1050;
  246. // canvas.height = 1485;
  247. // wx.canvasToTempFilePath({
  248. // x: 0,
  249. // y: 0,
  250. // width: canvas.width,
  251. // height: canvas.height,
  252. // canvas: canvas,
  253. // success: function(res2) {
  254. // that.saveImage();
  255. // }
  256. // });
  257. // });
  258. // }
  259. // else {
  260. that.saveImage();
  261. // }
  262. } else {
  263. this.setData({
  264. ShowLoading: false,
  265. });
  266. wx.showModal({
  267. title: "没有错题",
  268. showCancel: false,
  269. content: "先到“对答案”中给做错的题目打记号(点击题目序号)",
  270. });
  271. }
  272. },
  273. getAnswerID: function () {
  274. var list = wx.getStorageSync("AnswerList");
  275. var id = 1;
  276. if (list && list.length > 0) {
  277. list.sort(function (a, b) {
  278. return b.AnswerID - a.AnswerID;
  279. });
  280. id = list[0].AnswerID + 1;
  281. }
  282. for (var i = 0; i < this.data.PageNumber; i++)
  283. arrAnswerID.push(id + i);
  284. },
  285. saveImage: function () {
  286. var that = this;
  287. var item = QuestionItem;
  288. item.AnswerID = arrAnswerID.shift();
  289. const query = wx.createSelectorQuery();
  290. query.select('#Canvas')
  291. .fields({
  292. node: true,
  293. size: true
  294. })
  295. .exec((res) => {
  296. var canvas = res[0].node;
  297. var ctx = canvas.getContext('2d');
  298. canvas.width = 1050;
  299. canvas.height = 1485;
  300. ctx.textAlign="left";
  301. ctx.textBaseline="top";
  302. ctx.font = "12px";
  303. ctx.fillStyle="#ffffff";
  304. ctx.fillRect(0, 0, canvas.width, canvas.height);
  305. ctx.fillStyle = "#000000";
  306. var xStart = 60;
  307. var yStart = 247;
  308. var height = 150;
  309. if (item.QuestionTypeCategory == 2)
  310. height = 59;
  311. if (item.Category > 0) {
  312. if (item.PageCount == 18)
  313. height = 210;
  314. else if (item.PageCount == 15)
  315. height = 250;
  316. else if (item.PageCount == 9)
  317. height = 400;
  318. }
  319. //括号
  320. var index = 0;
  321. for (var i = 0; i < 3; i++) {
  322. for (var j = 0; j < item.PageCount / 3; j++) {
  323. index++;
  324. if (index <= item.QuestionList.length) {
  325. ctx.fillText("(", xStart + i * 310, yStart + j * height);
  326. ctx.fillText(")", xStart + i * 310 + 22, yStart + j * height);
  327. }
  328. }
  329. }
  330. //编号
  331. index = 0;
  332. ctx.textAlign="center";
  333. var numberLeft = 12;
  334. if (isAndroid)
  335. numberLeft = 14;
  336. for (var i = 0; i < 3; i++) {
  337. for (var j = 0; j < item.PageCount / 3; j++) {
  338. index++;
  339. if (index <= item.QuestionList.length) {
  340. ctx.fillText(index, xStart + i * 310 + numberLeft, yStart + j * height);
  341. }
  342. }
  343. }
  344. //算式
  345. index = that.data.arrPage.length * item.PageCount;
  346. //ctx.setFontSize(24);
  347. ctx.font = "24px";
  348. var urlDiv=[];
  349. for (var i = 0; i < 3; i++) {
  350. for (var j = 0; j < item.PageCount / 3; j++) {
  351. index++;
  352. if (index <= item.QuestionList.length) {
  353. //横式
  354. if (item.QuestionTypeCategory == 2) {
  355. var A = item.QuestionList[index - 1].A.toString();
  356. if (item.QuestionList[index - 1].HiddenColumn == "A")
  357. A = "____";
  358. var OperateAB = item.QuestionList[index - 1].OperateAB.toString();
  359. //console.log(OperateAB);
  360. var B = item.QuestionList[index - 1].B.toString();
  361. if (item.QuestionList[index - 1].HiddenColumn == "B")
  362. B = "____";
  363. var equation = A + " " + OperateAB + " " + B;
  364. if (item.QuestionList[index - 1].C) {
  365. var OperateBC = item.QuestionList[index - 1].OperateBC.toString();
  366. var C = item.QuestionList[index - 1].C.toString();
  367. equation += " " + OperateBC + " " + C;
  368. if (item.QuestionList[index - 1].D) {
  369. var OperateCD = item.QuestionList[index - 1].OperateCD.toString();
  370. var D = item.QuestionList[index - 1].D.toString();
  371. equation += " " + OperateCD + " " + D;
  372. }
  373. }
  374. equation += " = ";
  375. var R = item.QuestionList[index - 1].R.toString();
  376. if (item.QuestionList[index - 1].HiddenColumn == "R")
  377. R = "";
  378. equation += R;
  379. var num = xStart + i * 310 + 31;
  380. for (var n = 0; n < equation.length; n++) {
  381. var len = getLength(equation[n]);
  382. num += len;
  383. if (equation[n] == ".") {
  384. ctx.fillText(equation[n], num + 3, yStart + j * 59 - 5);
  385. } else {
  386. var h = -8;
  387. if (equation[n] == "_")
  388. h = 0;
  389. ctx.fillText(equation[n], num, yStart + j * 59 + h);
  390. }
  391. }
  392. }
  393. //竖式
  394. else if (item.QuestionTypeCategory == 3) {
  395. var num1 = item.QuestionList[index - 1];
  396. var isAnswer = false;
  397. var width = 250;
  398. if (num1.OperateAB == "÷")
  399. width = 240;
  400. for (var n = 0; n < num1.Vertical.length; n++) {
  401. var num = xStart + i * 310 + width;
  402. var num2 = 0;
  403. for (var m = num1.Vertical[n].Array.length - 1; m >= 0; m--) {
  404. var str = "";
  405. if (num1.Vertical[n].Type == "line") {
  406. if (num1.OperateAB != "÷") {
  407. //var lineLength = num1.Vertical[n].Array.length * 30 + 20;
  408. var lineLength = 6 * 30 + 20;
  409. var lineTop = 4;
  410. //console.log(yStart + j * height + n * 30 + lineTop);
  411. ctx.moveTo(num, yStart + j * height + n * 30 + lineTop);
  412. ctx.lineTo(num - lineLength, yStart + j * height + n * 30 + lineTop);
  413. ctx.stroke();
  414. isAnswer = true;
  415. break;
  416. }
  417. } else {
  418. str = num1.Vertical[n].Array[m];
  419. if (num1.OperateAB == "÷" && str == "√") {
  420. isAnswer = true;
  421. var lineLength = num1.A.toString().length;
  422. var lineWidth = Math.floor(57 * (1 + num1.A.toString().length) / 2);
  423. var obj={};
  424. obj.url="../images/formula_division_size0" + lineLength + ".png";
  425. obj.num1=num - (num1.Vertical[n].Array.length - m) * 30 - 8;
  426. obj.num2=yStart + j * height + n * 30 - 10;
  427. obj.num3=lineWidth;
  428. obj.num4=39;
  429. urlDiv.push(obj);
  430. // var img = canvas.createImage();
  431. // img.src = "../images/formula_division_size0" + lineLength + ".png";
  432. // console.log(img.src);
  433. // img.onload = e => {
  434. // ctx.drawImage(img, num - (num1.Vertical[n].Array.length - m) * 30 - 8, yStart + j * height + n * 30 - 10, lineWidth, 39);
  435. // };
  436. }
  437. else if (num1.OperateAB == "÷" && n == 0) {} else if (num1.OperateAB == "÷" && n == 1) {
  438. ctx.fillText(str, num - (num1.Vertical[n].Array.length - m) * 10, yStart + j * height + n * 30);
  439. }
  440. else {
  441. if (str == ".") {
  442. ctx.fillText(str, num - (num1.Vertical[n].Array.length - m) * 30 + 15, yStart + j * height + n * 30);
  443. num2 = 30;
  444. } else if (str == "+" || str == "-" || str == "−" || str == "×" || str == "÷") {
  445. var lineLength = 6 * 30;
  446. ctx.fillText(str, num - lineLength, yStart + j * height + n * 30);
  447. num2 = 30;
  448. } else
  449. ctx.fillText(str, num - (num1.Vertical[n].Array.length - m) * 30 + num2, yStart + j * height + n * 30);
  450. }
  451. }
  452. }
  453. if (isAnswer)
  454. break;
  455. }
  456. }
  457. }
  458. }
  459. }
  460. ctx.textAlign="left";
  461. //ctx.setFontSize(32);
  462. ctx.font = "32px";
  463. ctx.fillText(item.Name, 60, 45);
  464. //ctx.setFontSize(12);
  465. ctx.font = "12px";
  466. ctx.fillText(item.CategoryName, 60, 90);
  467. ctx.fillText("共" + item.PageCount + "道题", 60, 125);
  468. ctx.fillText("第 "+(pageIndex+1).toString()+" / "+that.data.PageNumber+" 页", 60, 147);
  469. ctx.fillText("答案检索号", 768, 60);
  470. ctx.textAlign="right";
  471. ctx.fillText("出题时间 " + item.CreateTime, 875, 94);
  472. ctx.fillText("微信扫一扫 计时看答案", 875, 111);
  473. ctx.fillText("《数学计算题》选题 打印 扫码 批改", 875, 137);
  474. ctx.font = "32px";
  475. ctx.fillText(item.AnswerID, 872, 50);
  476. var img=canvas.createImage();
  477. img.src="../images/answer.png";
  478. img.onload = e => {
  479. ctx.drawImage(img, 890, 54, 100, 100);
  480. if (urlDiv.length>0){
  481. var img2=canvas.createImage();
  482. img2.src=urlDiv[0].url;
  483. img2.onload = e => {
  484. for(var k=0;k<urlDiv.length;k++)
  485. ctx.drawImage(img2, urlDiv[k].num1, urlDiv[k].num2, urlDiv[k].num3, urlDiv[k].num4);
  486. build();
  487. };
  488. }
  489. else
  490. build();
  491. };
  492. function build(){
  493. var w = 1050,h = 1485;
  494. wx.canvasToTempFilePath({
  495. x: 0,
  496. y: 0,
  497. width: w * times,
  498. height: h * times,
  499. destWidth: w * times,
  500. destHeight: h * times,
  501. canvas: canvas,
  502. success: function (res2) {
  503. //console.log(res2.tempFilePath);
  504. that.data.arrPage.push(res2.tempFilePath);
  505. item.TempImagePath = res2.tempFilePath;
  506. tempAnswerList.push(JSON.parse(JSON.stringify(item)));
  507. that.setData({
  508. arrPage: that.data.arrPage,
  509. });
  510. if (that.data.arrPage.length < that.data.PageNumber) {
  511. pageIndex++;
  512. that.saveImage();
  513. } else {
  514. //生成图片完成
  515. setTimeout(function () {
  516. that.setData({
  517. ShowLoading: false,
  518. });
  519. wx.pageScrollTo({
  520. scrollTop: 0,
  521. duration: 300
  522. });
  523. //存列表
  524. var tempList = wx.getStorageSync("AnswerList");
  525. if (!tempList)
  526. tempList = [];
  527. for (var x = 0; x < tempList.length; x++) {
  528. tempList[x].IsNew = 0;
  529. }
  530. for (var x = 0; x < tempAnswerList.length; x++) {
  531. var tempItem = tempAnswerList[x];
  532. var id = x * tempItem.PageCount;
  533. var arr = [];
  534. for (var y = 0; y < tempItem.QuestionList.length; y++) {
  535. if (y >= id && y < id + tempItem.PageCount) {
  536. arr.push(tempItem.QuestionList[y]);
  537. }
  538. }
  539. tempItem.QuestionList = arr;
  540. tempItem.IsNew = 1;
  541. tempList.unshift(tempItem);
  542. }
  543. wx.setStorageSync("AnswerList", tempList);
  544. common.getStorageValue(that, "HelpHidden7", false, function () {
  545. that.showHelp2();
  546. });
  547. }, 3000);
  548. }
  549. }
  550. });
  551. };
  552. });
  553. function getLength(str) {
  554. switch (str) {
  555. case "0":
  556. case "1":
  557. case "2":
  558. case "3":
  559. case "4":
  560. case "5":
  561. case "6":
  562. case "7":
  563. case "8":
  564. case "9":
  565. return 15;
  566. case ".":
  567. return 8;
  568. default:
  569. return 12;
  570. }
  571. }
  572. },
  573. //保存图片文件
  574. saveImageFile: function () {
  575. if (this.data.IsDistabled == "") {
  576. wx.showLoading({
  577. title: "保存中..."
  578. });
  579. var that = this;
  580. var count = 0;
  581. for (var i = 0; i < that.data.arrPage.length; i++) {
  582. wx.saveImageToPhotosAlbum({
  583. filePath: that.data.arrPage[i],
  584. success(res3) {
  585. console.log("save:" + res3.savedFilePath);
  586. count++
  587. if (count == that.data.arrPage.length) {
  588. wx.hideLoading();
  589. wx.showModal({
  590. title: "保存完成",
  591. showCancel: false,
  592. content: "请打开手机相册查看图片!",
  593. });
  594. that.setData({
  595. IsDistabled: "Distabled",
  596. BtnText: "已保存",
  597. });
  598. wx.pageScrollTo({
  599. scrollTop: 400,
  600. duration: 300
  601. });
  602. }
  603. },
  604. fail(err3) {
  605. console.log(err3);
  606. wx.openSetting();
  607. },
  608. complete() {
  609. wx.hideLoading();
  610. }
  611. })
  612. }
  613. }
  614. },
  615. changePageNumber: function (e) {
  616. var id = Number(e.currentTarget.dataset.id);
  617. this.data.PageNumber += id;
  618. var addDisabled = "",
  619. subDisabled = "";
  620. if (this.data.PageNumber <= 1) {
  621. this.data.PageNumber = 1;
  622. subDisabled = "btnAddSubDisabled";
  623. } else if (this.data.PageNumber >= 4) {
  624. this.data.PageNumber = 4;
  625. addDisabled = "btnAddSubDisabled";
  626. }
  627. this.setData({
  628. PageNumber: this.data.PageNumber,
  629. AddDisabled: addDisabled,
  630. SubDisabled: subDisabled,
  631. });
  632. },
  633. showImage: function (e) {
  634. var that = this;
  635. var id = e.currentTarget.dataset.id;
  636. wx.previewImage({
  637. current: that.data.arrPage[id], // 当前显示图片的http链接
  638. urls: that.data.arrPage // 需要预览的图片http链接列表
  639. });
  640. },
  641. closeLoading: function () {
  642. var that = this;
  643. that.setData({
  644. ShowLoading: false,
  645. IsFinished: false,
  646. });
  647. },
  648. menuClick: function (e) {
  649. this.data.filter = e.currentTarget.dataset.id;
  650. if (this.data.filter == "horizontal") {
  651. this.data.PageCount = this.data.QuestionTypeItem.QuestionNumber2;
  652. } else if (this.data.filter == "vertical") {
  653. this.data.PageCount = this.data.QuestionTypeItem.QuestionNumber3;
  654. }
  655. this.setData({
  656. filter: this.data.filter,
  657. IsShowMenu: false,
  658. PageCount: this.data.PageCount,
  659. });
  660. },
  661. closeMenu: function () {
  662. this.setData({
  663. IsShowMenu: false,
  664. });
  665. },
  666. openMenu: function () {
  667. this.setData({
  668. IsShowMenu: true,
  669. });
  670. },
  671. showHelp: function () {
  672. if (!this.data.HelpHidden3) {
  673. this.audioCtx = wx.createAudioContext('myAudio');
  674. var str = "嘿嘿,找到我了吗?我在车间的窗户里制作例题呢。如果这是你要的题型,去点“出题”按钮就对了。还要告诉你,一张卷子就是一张图片,题目数量请看提示。";
  675. server.playAudio(this.audioCtx, str);
  676. }
  677. },
  678. closeHelp: function () {
  679. this.setData({
  680. HelpHidden3: true,
  681. });
  682. wx.setStorageSync("HelpHidden3", true);
  683. this.audioCtx = wx.createAudioContext('myAudio');
  684. this.audioCtx.pause();
  685. },
  686. showHelp2: function () {
  687. if (!this.data.HelpHidden7) {
  688. this.audioCtx = wx.createAudioContext('myAudio');
  689. var str = "卷子出炉咯,棒棒哒!快去手机相册打印吧。我会等在首页上的答案资料室为你继续带路的。";
  690. server.playAudio(this.audioCtx, str);
  691. }
  692. },
  693. closeHelp2: function () {
  694. this.setData({
  695. HelpHidden7: true,
  696. });
  697. wx.setStorageSync("HelpHidden7", true);
  698. this.audioCtx = wx.createAudioContext('myAudio');
  699. this.audioCtx.pause();
  700. },
  701. showHelp8: function () {
  702. if (!this.data.HelpHidden8) {
  703. this.audioCtx = wx.createAudioContext('myAudio');
  704. var str = "发现错误是提高成绩的第一步。点一下题目数量右侧的图标,当有错题后,能查看和整理错题清单。";
  705. server.playAudio(this.audioCtx, str);
  706. }
  707. },
  708. closeHelp8: function () {
  709. this.setData({
  710. HelpHidden8: true,
  711. });
  712. wx.setStorageSync("HelpHidden8", true);
  713. this.audioCtx = wx.createAudioContext('myAudio');
  714. this.audioCtx.pause();
  715. },
  716. onShareAppMessage: function () {
  717. return {
  718. title: app.globalData.ShareTitle,
  719. path: 'pages/index/index?UserID=' + app.globalData.userInfo.UserID,
  720. imageUrl: app.globalData.ShareImage,
  721. }
  722. },
  723. })