xinindex.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  1. // pages/index/jingdianchaxun/jingdianchaxun.js
  2. const app = getApp()
  3. Page({
  4. data: {
  5. layoutType: 'default',
  6. layoutConfig: {},
  7. featureLayout: [],
  8. latitude: 36.5,
  9. longitude: 118.0,
  10. scale: 7,
  11. showImageModal: false,
  12. currentMarker: null,
  13. showWebView: false,
  14. webViewUrl: "",
  15. currentVrTitle: "",
  16. searchText: "",
  17. // 新增控制变量
  18. showSearchMarkers: false,
  19. searchMarkers: [] , // 新增绿色搜索标记
  20. markers: [
  21. {
  22. id: 1,
  23. latitude: 36.665282,
  24. longitude: 117.119999,
  25. width: 30, // 添加宽度
  26. height: 30, // 添加高度
  27. title: '济南战役纪念馆',
  28. address: '市中区英雄山路18号',
  29. iconPath: '/images/red-marker.png',
  30. callout: {
  31. content: '济南战役纪念馆\n华东地区规模最大的革命烈士纪念地',
  32. color: '#000',
  33. fontSize: 14,
  34. borderRadius: 5,
  35. bgColor: '#fff',
  36. padding: 5,
  37. display: 'ALWAYS'
  38. },
  39. imageUrl: 'https://smp.ouc.edu.cn/_upload/article/images/f5/0d/85b29d70430a9261ef3830f24970/959ccc6d-b829-4d3f-8335-2c776c9faca7.png',
  40. description: '济南革命烈士陵园,坐落在泉城济南英雄山风景区,占地480亩,于1949年建成。陵园分为革命烈士纪念塔、济南战役纪念馆、革命烈士墓区、"胜利"铜雕、毛泽东主席凭吊革命烈士纪念亭和济南革命烈士纪念群雕等纪念建筑物。陵园以济南战役纪念馆为中心,形成了辐射全市范围的红色旅游景区。是山东省规模最大的烈士陵园,1977年被公布为山东省第一批重点文物保护单位。',
  41. detail: [
  42. { label: '开放时间', value: '9:00-16:00(周一闭馆,周二至周日开馆)' },
  43. { label: '门票', value: '免费' }
  44. ]
  45. },
  46. {
  47. id: 2,
  48. latitude: 36.090839,
  49. longitude: 120.384428,
  50. title: '青岛革命烈士纪念馆',
  51. address: '市南区芝泉路6号',
  52. width: 30, // 添加宽度
  53. height: 30, // 添加高度
  54. iconPath: '/images/red-marker.png',
  55. callout: {
  56. content: '青岛革命烈士纪念馆\n山东省重点文物保护单位',
  57. color: '#000',
  58. fontSize: 14,
  59. borderRadius: 5,
  60. bgColor: '#fff',
  61. padding: 5,
  62. display: 'ALWAYS'
  63. },
  64. imageUrl: 'https://bkimg.cdn.bcebos.com/pic/730e0cf3d7ca7bcb0a463bb5de507c63f6246a6002ad?x-bce-process=image/format,f_auto/quality,Q_70/resize,m_lfit,limit_1,w_536',
  65. description: '青岛市革命烈士纪念馆(青岛市烈士纪念设施保护中心)位于市南区芝泉路6号,建立于1977年,1981年6月对外开放,占地面积35512平方米,总建筑面积4050平方米。主要纪念设施有烈士纪念堂、抗战馆、军魂馆、"山河魂"烈士群雕、烈士英名碑、流芳亭等。主要承担烈士纪念活动、烈士纪念设施保护及宣教褒扬等工作。被评为国家级烈士纪念设施,国家、省、市爱国主义教育基地,山东省党史教育基地,山东省国防教育基地,山东省党员教育基地,山东省退役军人思想政治教育基地等。',
  66. detail: [
  67. { label: '开放时间', value: '9:00-16:30(周一闭馆)' },
  68. { label: '门票', value: '免费' }
  69. ]
  70. },
  71. {
  72. id: 3,
  73. latitude: 36.804685,
  74. longitude: 118.055008,
  75. title: '黑铁山抗日武装起义纪念馆',
  76. address: '张店区四宝山街道',
  77. width: 30, // 添加宽度
  78. height: 30, // 添加高度
  79. iconPath: '/images/red-marker.png',
  80. callout: {
  81. content: '黑铁山起义纪念地\n山东抗日三大起义之一',
  82. color: '#000',
  83. fontSize: 14,
  84. borderRadius: 5,
  85. bgColor: '#fff',
  86. padding: 5,
  87. display: 'ALWAYS'
  88. },
  89. imageUrl: 'https://bkimg.cdn.bcebos.com/pic/d8f9d72a6059252dd42a4051e4c8143b5bb5c9ea1310?x-bce-process=image/format,f_auto/watermark,image_d2F0ZXIvYmFpa2UyNzI,g_7,xp_5,yp_5,P_20/resize,m_lfit,limit_1,h_1080',
  90. description: '黑铁山抗日武装起义纪念馆于1995年纪念抗日战争胜利50周年之际奠基,于1996年8月1日落成开馆。由张店区委区政府发出倡议,号召张店区党政机关、人民大众捐资160万元而兴建。主体为二层楼,建筑面积1300平方米。为淄博市市级重点烈士纪念建筑物保护单位、山东省爱国主义教育基地。',
  91. detail: [
  92. { label: '开放时间', value: '上午8:30-11:30 下午13:30-17:00(周一闭馆)' },
  93. { label: '门票', value: '具体收费情况以现场公示为主' }
  94. ]
  95. },
  96. {
  97. id: 4,
  98. latitude: 34.810488,
  99. longitude: 117.323725,
  100. title: '台儿庄大战纪念馆',
  101. width: 30, // 添加宽度
  102. height: 30, // 添加高度
  103. address: '台儿庄区沿河南路6号',
  104. iconPath: '/images/red-marker.png',
  105. callout: {
  106. content: '台儿庄大战纪念馆\n抗日战争正面战场首次重大胜利',
  107. color: '#000',
  108. fontSize: 14,
  109. borderRadius: 5,
  110. bgColor: '#fff',
  111. padding: 5,
  112. display: 'ALWAYS'
  113. },
  114. imageUrl: 'https://bkimg.cdn.bcebos.com/pic/58ee3d6d55fbb2fbee8d1683414a20a44723dcf9?x-bce-process=image/format,f_auto/watermark,image_d2F0ZXIvYmFpa2UyNzI,g_7,xp_5,yp_5,P_20/resize,m_lfit,limit_1,h_1080',
  115. description: '台儿庄大战纪念馆,位于山东省枣庄市台儿庄区城区西南郊,是为了纪念抗日战争初期著名的台儿庄战役而修建,于1992年由台儿庄区人民政府筹资建成,1993年4月8日正式对外开放,后经扩建,占地面积达96亩,建筑面积1.2万平方米。台儿庄大战纪念馆由纪念碑、陈列馆、影视馆、全景画馆、战地记者馆、无名英雄墓、国防教育园等部分组成,并设有临时展厅、多功能报告厅和红色图书室。展出文物、图片和史料2000余件,通过历史文物、历史图片、文献资料与各类辅助陈列手段的有机结合,全景再现台儿庄大战中爱国将士报效祖国的壮举。截至2022年底,馆有藏品数量6598件/套,年度观众总数为155323人。台儿庄大战纪念馆是全国百家爱国主义教育示范基地、全国中小学爱国主义教育基地、中国侨联爱国主义教育基地、国家首批国防教育示范基地、国家AAAA级旅游景区,并曾多年获评"山东省文明单位"。2014年8月24日,台儿庄大战纪念馆被列入《第一批国家级抗战纪念设施、遗址名录》。',
  116. detail: [
  117. { label: '开放时间', value: '8:00-17:00(全年)' },
  118. { label: '门票', value: '免费' }
  119. ]
  120. },
  121. {
  122. id: 5,
  123. latitude: 37.058161,
  124. longitude: 118.406168,
  125. width: 30, // 添加宽度
  126. height: 30, // 添加高度
  127. title: '东营市历史博物馆',
  128. address: '广饶街道月河路270号',
  129. iconPath: '/images/red-marker.png',
  130. callout: {
  131. content: '东营市历史博物馆\n中共刘集支部旧址所在地',
  132. color: '#000',
  133. fontSize: 14,
  134. borderRadius: 5,
  135. bgColor: '#fff',
  136. padding: 5,
  137. display: 'ALWAYS'
  138. },
  139. imageUrl: 'https://bkimg.cdn.bcebos.com/pic/6a600c338744ebf816436f04d8f9d72a6059a7de?x-bce-process=image/format,f_auto/resize,m_lfit,limit_1,w_504',
  140. description: '东营市历史博物馆成立于1993年5月,坐落在东营市南部的广饶县城,东连关帝庙和孙武祠,南临月河公园,西靠月河路,北依广饶宾馆,占地面积30余亩。新馆于2002年1月开工建设,2003年10月建成,总建筑面积6812平方米,全框架结构,外观庄重大方,地上三层,地下一层,陈列总面积3500平方米。',
  141. detail: [
  142. { label: '开放时间', value: '夏8: 00 —11:30,14:00—17:30;冬8: 00 —11:30,13:30—17:00(周一闭馆)' },
  143. { label: '门票', value: '免费' }
  144. ]
  145. },
  146. {
  147. id: 6,
  148. latitude: 37.540619,
  149. longitude: 121.390736,
  150. width: 30, // 添加宽度
  151. height: 30, // 添加高度
  152. title: '胶东革命纪念馆',
  153. address: '芝罘区海岸路20号',
  154. iconPath: '/images/red-marker.png',
  155. callout: {
  156. content: '胶东革命纪念馆\n胶东地区革命历史展示中心',
  157. color: '#000',
  158. fontSize: 14,
  159. borderRadius: 5,
  160. bgColor: '#fff',
  161. padding: 5,
  162. display: 'ALWAYS'
  163. },
  164. imageUrl: 'https://bkimg.cdn.bcebos.com/pic/c8177f3e6709c93d70cf743ec971efdcd100bba1feec?x-bce-process=image/format,f_auto/quality,Q_70/resize,m_lfit,limit_1,w_536',
  165. description: '胶东革命纪念馆位于烟台,占地面积5600平方米,展陈面积2800平方米,旧址于1865年修建,是全国重点文物保护单位。2018年7月1日起,该馆面向市民免费开放,每周一、周四闭馆。基本陈列包括英雄胶东、奋发图强、走向辉煌三个部分,展示了胶东人民在中国共产党领导下近百年来从苦难到辉煌。',
  166. detail: [
  167. { label: '开放时间', value: '9:00——16:00(每周一、周四闭馆法定节假日除外)' },
  168. { label: '门票', value: '免费' }
  169. ]
  170. },
  171. {
  172. id: 7,
  173. latitude: 36.707668,
  174. longitude: 119.161748,
  175. width: 30, // 添加宽度
  176. height: 30, // 添加高度
  177. title: '潍县集中营旧址',
  178. address: '奎文区广文街道',
  179. iconPath: '/images/red-marker.png',
  180. callout: {
  181. content: '潍县集中营旧址\n二战期间亚洲最大侨民集中营',
  182. color: '#000',
  183. fontSize: 14,
  184. borderRadius: 5,
  185. bgColor: '#fff',
  186. padding: 5,
  187. display: 'ALWAYS'
  188. },
  189. imageUrl: 'https://www.iwenbo.fun/storage/heritage/20210131/60169f37505f5.jpg',
  190. description: '潍县西方侨民集中营旧址,又名乐道院集中营、山东集中营,位于山东省潍坊市奎文区乐道院。清光绪八年(1882年),美国基督教长老会派牧师狄乐播偕夫人阿撤拉氏(一说为狄珍珠)来潍县传教,在老潍县东关处买地建立"乐道院",乐道院由教堂、学堂、诊所3部分组成,用以传教、办学和开办诊所。民国三十一年(1942年)至民国三十四年(1945年),日军在潍县西方侨民集中营旧址设立"敌国人员生活所",一度成为二战期间亚洲境内最大的"集中营"。从1996年起,潍坊市政府先后投资对潍县西方侨民集中营旧址十字楼进行了修缮,建设纪念碑和乐道广场、乐道雕塑,建成展览馆和陈列馆,并对周边河道进行了治理,进行"乐道钟声"景观公园建设,对观众免费开放。作为二战期间亚洲最大的外国侨民集中营旧址——潍县西方侨民集中营旧址,承载着世界反法西斯战争共同的伤痛记忆,对于拓宽公共外交空间具有不可替代的地位和重要作用。2019年10月,潍县西方侨民集中营旧址被中华人民共和国国务院公布为第八批全国重点文物保护单位。',
  191. detail: [
  192. { label: '开放时间', value: '夏9:00-17:00;冬9:00-16:30(周一闭馆)' },
  193. { label: '门票', value: '免费' }
  194. ]
  195. },
  196. {
  197. id: 8,
  198. latitude: 35.414921,
  199. longitude: 116.587116,
  200. width: 30, // 添加宽度
  201. height: 30, // 添加高度
  202. title: '微山湖抗日英烈纪念园',
  203. address: '微山县微山岛镇',
  204. iconPath: '/images/red-marker.png',
  205. callout: {
  206. content: '微山湖抗日纪念园\n铁道游击队主要活动区域',
  207. color: '#000',
  208. fontSize: 14,
  209. borderRadius: 5,
  210. bgColor: '#fff',
  211. padding: 5,
  212. display: 'ALWAYS'
  213. },
  214. imageUrl: 'https://bkimg.cdn.bcebos.com/pic/34fae6cd7b899e510fb319ddf4fece33c895d043a7fb?x-bce-process=image/format,f_auto/watermark,image_d2F0ZXIvYmFpa2UyNzI,g_7,xp_5,yp_5,P_20/resize,m_lfit,limit_1,h_1080',
  215. description: '微山湖英烈纪念园,位于山东省微山县夏镇西港,始建于1982年,共投资1100余万元,占地33000平方米,原名为微山县烈士陵园,是为纪念微山湖区革命武装和湖区人民团结抗日,浴血奋战而修建的烈士纪念设施。微山湖英烈纪念园内安葬不同时期牺牲的革命烈士587名。著名烈士有"华东战斗英雄"郭继胜、抗日英雄褚雅青、爆破英雄种衍海等。著名战斗主要有杏园战斗、部城遭遇战、收复微山岛、大捐战斗、南庄战斗、程子庙战斗等。纪念园内主要建筑物有微山湖抗日游击大队纪念碑、微山县烈士英名碑、著名烈士墓区、鲁南战役烈士纪念碑、微山湖区党史纪念馆、文史馆等。整座纪念园布局严谨,绿草如茵,松柏苍翠。2014年,经济宁市人民政府批准,微山湖英烈纪念园被列入市级烈士纪念设施保护单位。',
  216. detail: [
  217. { label: '开放时间', value: '8:30—17:30(农历除夕至大年初三闭园)' },
  218. { label: '门票', value: '免费' }
  219. ]
  220. },
  221. {
  222. id: 9,
  223. latitude: 36.200371,
  224. longitude: 117.087614,
  225. width: 30, // 添加宽度
  226. height: 30, // 添加高度
  227. title: '陆房突围胜利纪念馆',
  228. address: '肥城市安临站镇',
  229. iconPath: '/images/red-marker.png',
  230. callout: {
  231. content: '陆房突围纪念馆\n八路军115师突围战纪念地',
  232. color: '#000',
  233. fontSize: 14,
  234. borderRadius: 5,
  235. bgColor: '#fff',
  236. padding: 5,
  237. display: 'ALWAYS'
  238. },
  239. imageUrl: 'https://tse2-mm.cn.bing.net/th/id/OIP-C.rMYotSx3O8zaY_LHeW03NgHaE8?w=246&h=180&c=7&r=0&o=7&dpr=1.8&pid=1.7&rm=3',
  240. description: '陆房突围胜利纪念馆是为纪念1939年八路军一一五师陆房突围战役而设立的专题纪念馆。该馆始建于1971年,2015年完成扩建后建筑面积达5300平方米,现陈列包含战斗文物、历史文献及军民生活用品等260件/套藏品。截至2023年,年接待量达18万人次,累计接待单位400余个。2024年8月获评国家二级博物馆,同时被列为国家级抗战纪念设施、遗址及省级爱国主义教育基地',
  241. detail: [
  242. { label: '开放时间', value: '夏9:00 - 11:30,15:00 - 17:30;冬9:00 - 11:30,14:30 - 17:00(周一闭馆)' },
  243. { label: '门票', value: '免费' }
  244. ]
  245. },
  246. {
  247. id: 10,
  248. latitude: 37.501314,
  249. longitude: 122.113556,
  250. width: 30, // 添加宽度
  251. height: 30, // 添加高度
  252. title: '天福山起义纪念馆',
  253. address: '文登区天福山',
  254. iconPath: '/images/red-marker.png',
  255. callout: {
  256. content: '天福山起义纪念馆\n山东人民抗日救国军诞生地',
  257. color: '#000',
  258. fontSize: 14,
  259. borderRadius: 5,
  260. bgColor: '#fff',
  261. padding: 5,
  262. display: 'ALWAYS'
  263. },
  264. imageUrl: 'https://example.com/tianfu-mountain.jpg',
  265. description: '天福山起义纪念馆位于山东省威海市文登区文登营镇天福山森林公园中心,建筑面积450平方米,陈列面积420平方米。1989年,拆除原有简易展厅,在原址上重新扩建420平方米平房展厅。主要陈列有《天福山起义原址》《中共胶东特委会议旧址》《天福山武装起义会场》《天福山起义纪念塔》等。主要藏品有《三军战士用过的枪支》《军旗、军号、印鉴》《大刀、铁矛头、节鞭》等文物藏品。截至2019年末,天福天福山起义纪念馆先后获得"山东省爱国主义教育基地"、"山东省优秀国防教育基地"等荣誉称号。',
  266. detail: [
  267. { label: '开放时间', value: '8:30-11:00,13:30-17:00(周一闭馆)' },
  268. { label: '门票', value: '免费' }
  269. ]
  270. }
  271. ],
  272. storyList: [
  273. {
  274. id: 1,
  275. cover: '/images/index/台儿庄.jpg',
  276. title: '台儿庄战役'
  277. },
  278. {
  279. id: 2,
  280. cover: '/images/index/沂蒙山革命.webp',
  281. title: '沂蒙山革命'
  282. },
  283. {
  284. id: 3,
  285. cover: '/images/index/济南革命烈士.jpg',
  286. title: '济南革命烈士'
  287. },
  288. {
  289. id: 4,
  290. cover: '/images/index/铁道游击队.webp',
  291. title: '铁道游击队'
  292. },
  293. {
  294. id: 5,
  295. cover: '/images/index/莱芜战役.jpg',
  296. title: '莱芜战役'
  297. },
  298. {
  299. id: 6,
  300. cover: '/images/index/羊山战役.png',
  301. title: '阳山战役'
  302. }
  303. ],
  304. vrList: [
  305. {
  306. id: 1,
  307. title: "聊城革命烈士陵园",
  308. desc: "360°全景展示",
  309. thumb: "https://bkimg.cdn.bcebos.com/pic/43a7d933c895d143ad4bb00002a995025aafa40fa9c5?x-bce-process=image/format,f_auto/quality,Q_70/resize,m_lfit,limit_1,w_536",
  310. url: "https://www.720yun.com/vr/f27j5puurv1"
  311. },
  312. {
  313. id: 2,
  314. title: "台儿庄大战纪念馆",
  315. desc: "沉浸式VR体验",
  316. thumb: "https://bkimg.cdn.bcebos.com/pic/58ee3d6d55fbb2fbee8d1683414a20a44723dcf9?x-bce-process=image/format,f_auto/watermark,image_d2F0ZXIvYmFpa2UyNzI,g_7,xp_5,yp_5,P_20/resize,m_lfit,limit_1,h_1080",
  317. url: "https://www.720yun.com/vr/6f4jtrwaOn5"
  318. },
  319. {
  320. id: 3,
  321. title: "鲁西南战役纪念馆",
  322. desc: "刘邓大军千里跃进",
  323. thumb: "https://bkimg.cdn.bcebos.com/pic/7a899e510fb30f2442a7769cd7dac643ad4bd113a557?x-bce-process=image/format,f_auto/quality,Q_70/resize,m_lfit,limit_1,w_536",
  324. url: "https://www.720yun.com/vr/a982acOfyna"
  325. },
  326. {
  327. id: 4,
  328. title: "孟良崮战役纪念馆",
  329. desc: "解放战争",
  330. thumb: "https://bkimg.cdn.bcebos.com/pic/b3119313b07eca806538b17b007280dda144ad342557?x-bce-process=image/format,f_auto/watermark,image_d2F0ZXIvYmFpa2UyNzI,g_7,xp_5,yp_5,P_20/resize,m_lfit,limit_1,h_1080",
  331. url: "https://www.720yun.com/vr/3d9jOstmrk2"
  332. },
  333. {
  334. id: 5,
  335. title: "昌邑抗日殉国烈士祠",
  336. desc: "全国重点文物保护单位",
  337. thumb: "http://www.changyibwg.cn/upload/default/20200509/756dff458ee61cb41428e42b9b2019e5.jpg",
  338. url: "https://www.720yun.com/vr/5fajOstmrk4"
  339. }
  340. ],
  341. touchStartX: 0,
  342. touchStartY: 0,
  343. positionX: 0,
  344. positionY: 0,
  345. showMenu: false,
  346. walking: false,
  347. windowWidth: 0,
  348. windowHeight: 0
  349. },
  350. onLoad: function(options) {
  351. this.getLayoutRecommendation();
  352. this.mapCtx = wx.createMapContext('map');
  353. wx.getSystemInfo({
  354. success: (res) => {
  355. this.setData({
  356. windowWidth: res.windowWidth,
  357. windowHeight: res.windowHeight,
  358. positionX: res.windowWidth - 80,
  359. positionY: res.windowHeight - 180
  360. });
  361. }
  362. });
  363. },
  364. getLayoutRecommendation() {
  365. wx.request({
  366. url: 'http://127.0.0.1:8000/api/recommend-layout/',
  367. method: 'GET',
  368. header: {
  369. 'Authorization': `Token ${app.globalData.userInfo.token}`
  370. },
  371. success: (res) => {
  372. console.log('布局推荐:', res.data);
  373. this.setData({
  374. layoutType: res.data.layout_type,
  375. featureWeights: res.data.feature_weights
  376. });
  377. },
  378. fail: (err) => {
  379. console.error('获取布局失败:', err);
  380. }
  381. });
  382. },
  383. generateFeatureLayout(weights) {
  384. // 根据权重生成特征布局
  385. const features = [
  386. {feature: 'ai-plan', name: '红途定制', image: '/images/index/生成攻略.png'},
  387. {feature: 'gongjiao', name: '游学路线', image: '/images/index/游学路线.png'},
  388. {feature: 'search', name: '红游速搜', image: '/images/搜索分类.png'},
  389. {feature: 'quiz', name: '红史问答', image: '/images/quiz-icon.png'}
  390. ];
  391. // 根据权重排序
  392. return features.sort((a, b) => weights[b.feature] - weights[a.feature])
  393. .map((item, index) => ({
  394. ...item,
  395. size: this.getSizeClass(index)
  396. }));
  397. },
  398. getSizeClass(index) {
  399. // 根据位置决定大小
  400. return index === 0 ? 'large' : (index < 3 ? 'medium' : 'small');
  401. },
  402. applyLayoutStyle() {
  403. // 动态应用布局样式
  404. const config = this.data.layoutConfig;
  405. const query = wx.createSelectorQuery();
  406. query.select('.map-container').boundingClientRect();
  407. query.select('.menu').boundingClientRect();
  408. query.select('.vr-container').boundingClientRect();
  409. query.exec(res => {
  410. res[0].node.setStyle({height: `${config.map * 100}vh`});
  411. res[1].node.setStyle({display: config.features > 0.3 ? 'block' : 'none'});
  412. res[2].node.setStyle({height: `${config.vr * 100}vh`});
  413. });
  414. },
  415. onSearchInput: function(e) {
  416. this.setData({
  417. searchText: e.detail.value
  418. });
  419. },
  420. searchLocation: function(keyword) {
  421. const qqMapKey = 'LOABZ-FH4LW-PGHRL-Y73W4-7WMNF-BHFQ5'; // 您的真实KEY
  422. wx.request({
  423. url: `https://apis.map.qq.com/ws/place/v1/search`,
  424. data: {
  425. keyword: keyword,
  426. boundary: 'region(山东,0)', // 限定山东范围
  427. key: qqMapKey
  428. },
  429. success: (res) => {
  430. wx.hideLoading();
  431. if (res.data.status === 0 && res.data.data) {
  432. this.processSearchResults(res.data.data);
  433. } else {
  434. wx.showToast({
  435. title: res.data.message || '搜索失败',
  436. icon: 'none'
  437. });
  438. }
  439. },
  440. fail: (err) => {
  441. wx.hideLoading();
  442. console.error('API请求失败:', err);
  443. }
  444. });
  445. },
  446. addMarker: function(location) {
  447. if (!this.mapCtx) {
  448. this.mapCtx = wx.createMapContext('map');
  449. }
  450. const newMarker = {
  451. id: Date.now(),
  452. latitude: location.lat,
  453. longitude: location.lng,
  454. title: location.name,
  455. iconPath: '/images/地点.png',
  456. width: 30,
  457. height: 30,
  458. callout: {
  459. content: location.name,
  460. color: '#fff',
  461. bgColor: '#d32f2f',
  462. padding: 8,
  463. borderRadius: 4
  464. },
  465. imageUrl: location.imageUrl || '/images/default.jpg',
  466. address: location.address,
  467. description: location.description,
  468. detail: location.detail || []
  469. };
  470. this.setData({
  471. latitude: location.lat,
  472. longitude: location.lng,
  473. scale: 12,
  474. markers: [newMarker]
  475. });
  476. this.mapCtx.moveToLocation();
  477. setTimeout(() => {
  478. this.mapCtx.translateMarker({
  479. markerId: newMarker.id,
  480. autoRotate: true,
  481. duration: 1000
  482. });
  483. }, 500);
  484. },
  485. // 点击按钮触发位置选择
  486. chooseLocation: function() {
  487. const that = this;
  488. wx.chooseLocation({
  489. success: (res) => {
  490. console.log('选择的位置:', res);
  491. // 生成绿色搜索标记(与原有红色标记共存)
  492. const newMarker = {
  493. id: Date.now(), // 动态ID避免冲突
  494. latitude: res.latitude,
  495. longitude: res.longitude,
  496. title: res.name || '已选位置',
  497. address: res.address,
  498. iconPath: '/images/search-marker.png', // 绿色标记图标
  499. width: 30,
  500. height: 30,
  501. callout: {
  502. content: res.name,
  503. color: '#fff',
  504. bgColor: '#07c160',
  505. padding: 8,
  506. display: 'ALWAYS'
  507. }
  508. };
  509. that.setData({
  510. searchMarkers: [newMarker], // 替换旧搜索标记
  511. latitude: res.latitude, // 移动视角到选中位置
  512. longitude: res.longitude,
  513. scale: 16
  514. });
  515. },
  516. fail: (err) => {
  517. console.error('位置选择失败:', err);
  518. wx.showToast({ title: '位置选择取消', icon: 'none' });
  519. }
  520. });
  521. },
  522. onSearchConfirm: function() {
  523. wx.request({
  524. url: 'https://apis.map.qq.com/ws/place/v1/search',
  525. success: (res) => {
  526. this.setData({
  527. // 生成绿色搜索标记(ID从10000开始避免冲突)
  528. searchMarkers: res.data.data.map((item, index) => ({
  529. id: 10000 + index,
  530. latitude: item.location.lat,
  531. longitude: item.location.lng,
  532. title: item.title,
  533. iconPath: '/images/search-marker.png', // 绿色图标
  534. width: 30,
  535. height: 30,
  536. callout: {
  537. content: item.title,
  538. color: '#fff',
  539. bgColor: '#07c160', // 绿色背景
  540. display: 'BYCLICK' // 点击才显示,避免遮挡
  541. }
  542. })),
  543. // 保持原有视野不变(避免红色标记移出屏幕)
  544. latitude: this.data.latitude,
  545. longitude: this.data.longitude
  546. });
  547. }
  548. });
  549. },
  550. // 在搜索成功的回调中:
  551. processSearchResults(results) {
  552. this.setData({
  553. searchMarkers: results.map((item, index) => ({
  554. id: 10000 + index, // 确保ID不冲突
  555. latitude: item.location.lat,
  556. longitude: item.location.lng,
  557. title: item.title,
  558. iconPath: '/images/search-marker.png',
  559. width: 30,
  560. height: 30
  561. })),
  562. showSearchMarkers: true,
  563. // 自动定位到第一个结果
  564. latitude: results[0].location.lat,
  565. longitude: results[0].location.lng,
  566. scale: 15
  567. });
  568. },// 标记点击事件处理(兼容原有红标和新绿标)
  569. onMarkerTap: function(e) {
  570. const markerId = e.detail.markerId;
  571. const redMarker = this.data.markers.find(m => m.id === markerId);
  572. if (redMarker) {
  573. this.setData({
  574. currentMarker: redMarker,
  575. showImageModal: true // 显示详情弹窗
  576. });
  577. return;
  578. }
  579. },
  580. hideImageModal: function() {
  581. this.setData({
  582. showImageModal: false
  583. });
  584. },
  585. stopPropagation: function() {
  586. return;
  587. },
  588. openLocation: function() {
  589. if (!this.data.currentMarker) return;
  590. wx.openLocation({
  591. latitude: this.data.currentMarker.latitude,
  592. longitude: this.data.currentMarker.longitude,
  593. name: this.data.currentMarker.title,
  594. address: this.data.currentMarker.address
  595. });
  596. },
  597. showWebView: function(e) {
  598. const { url, title } = e.currentTarget.dataset;
  599. wx.navigateTo({
  600. url: `/pages/vr-detail/vr-detail?url=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}`
  601. });
  602. },
  603. hideWebView: function() {
  604. this.setData({
  605. showWebView: false,
  606. webViewUrl: "",
  607. currentVrTitle: ""
  608. });
  609. },
  610. touchStart: function(e) {
  611. this.setData({
  612. touchStartX: e.touches[0].clientX,
  613. touchStartY: e.touches[0].clientY
  614. });
  615. },
  616. touchMove: function(e) {
  617. const { touchStartX, touchStartY } = this.data;
  618. const moveX = e.touches[0].clientX - touchStartX;
  619. const moveY = e.touches[0].clientY - touchStartY;
  620. this.setData({
  621. positionX: this.data.positionX + moveX,
  622. positionY: this.data.positionY + moveY,
  623. touchStartX: e.touches[0].clientX,
  624. touchStartY: e.touches[0].clientY
  625. });
  626. },
  627. touchEnd: function() {
  628. const { positionX, positionY, windowWidth, windowHeight } = this.data;
  629. const btnSize = 80;
  630. let finalX = positionX;
  631. let finalY = positionY;
  632. if (positionX < 0) finalX = 0;
  633. if (positionX > windowWidth - btnSize) finalX = windowWidth - btnSize;
  634. if (positionY < 0) finalY = 0;
  635. if (positionY > windowHeight - btnSize) finalY = windowHeight - btnSize;
  636. this.setData({
  637. positionX: finalX,
  638. positionY: finalY
  639. });
  640. },
  641. showFloatMenu: function() {
  642. this.setData({
  643. showMenu: true
  644. });
  645. },
  646. hideFloatMenu: function() {
  647. this.setData({
  648. showMenu: false
  649. });
  650. },
  651. doFunction1: function() {
  652. this.setData({ showMenu: false });
  653. wx.showToast({
  654. title: '功能1已触发',
  655. icon: 'none'
  656. });
  657. },
  658. doFunction2: function() {
  659. this.setData({ showMenu: false });
  660. wx.navigateTo({
  661. url: '/pages/function2/function2'
  662. });
  663. },
  664. doFunction3: function() {
  665. this.setData({ showMenu: false });
  666. wx.showModal({
  667. title: '提示',
  668. content: '确定执行功能3吗?',
  669. success(res) {
  670. if (res.confirm) {
  671. wx.showToast({
  672. title: '功能3已执行',
  673. icon: 'success'
  674. });
  675. }
  676. }
  677. });
  678. },
  679. navigateTopage: function(e) {
  680. const pagePath = e.currentTarget.dataset.url;
  681. if (pagePath) {
  682. wx.navigateTo({
  683. url: pagePath,
  684. });
  685. } else {
  686. wx.showToast({
  687. title: '功能开发中',
  688. icon: 'none'
  689. });
  690. }
  691. },
  692. viewGallery: function(e) {
  693. const id = e.currentTarget.dataset.id;
  694. wx.navigateTo({
  695. url: `/pages/gallery/detail?id=${id}`
  696. });
  697. },
  698. onReady: function() {
  699. // 页面初次渲染完成
  700. },
  701. onShow: function() {
  702. // 页面显示
  703. this.getRecommendLayout();
  704. },
  705. getRecommendLayout: function() {
  706. const token = wx.getStorageSync('token');
  707. if (!token) return;
  708. wx.request({
  709. url: 'https://your-api-domain.com/api/recommend-layout/',
  710. header: {
  711. 'Authorization': `Token ${token}`
  712. },
  713. success: (res) => {
  714. if (res.statusCode === 200) {
  715. console.log('布局推荐:', res.data);
  716. this.applyLayoutConfig(res.data);
  717. }
  718. }
  719. });
  720. },
  721. applyLayoutConfig: function(data) {
  722. const layoutMap = {
  723. 'map_focused': { map: 0.7, vr: 0.2 },
  724. 'vr_focused': { map: 0.4, vr: 0.4 },
  725. 'feature_focused': { map: 0.5, vr: 0.3 },
  726. 'default': { map: 0.6, vr: 0.3 }
  727. };
  728. // 设置布局类型
  729. const layoutType = data.layout_type || 'default';
  730. this.setData({
  731. layoutConfig: layoutMap[layoutType],
  732. featureLayout: this.generateFeatureLayout(data.recommended_order)
  733. });
  734. },
  735. // 生成功能布局
  736. generateFeatureLayout: function(features) {
  737. // 根据推荐顺序生成不同大小的布局项
  738. return features.map((feature, index) => {
  739. return {
  740. feature: feature,
  741. size: index < 2 ? 'large' : (index < 4 ? 'medium' : 'small')
  742. };
  743. }).slice(0, 6); // 只显示前6个功能
  744. },
  745. recordFeatureUsage(featureName) {
  746. const app = getApp();
  747. console.log('发送的Token:', app.globalData.userInfo.token);
  748. console.log('发送的featureName:', featureName);
  749. wx.request({
  750. url: 'http://127.0.0.1:8000/api/record-usage/',
  751. method: 'POST',
  752. header: {
  753. 'Authorization': `Token ${app.globalData.userInfo.token}`,
  754. 'Content-Type': 'application/json' // 确保这个请求头存在
  755. },
  756. data: JSON.stringify({ // 关键修改:必须使用JSON.stringify
  757. feature_name: featureName // 参数名必须与后端一致
  758. }),
  759. success: (res) => {
  760. console.log('行为记录响应:', res.data);
  761. },
  762. fail: (err) => {
  763. console.error('请求失败:', err);
  764. }
  765. });
  766. },
  767. onHide: function() {
  768. // 页面隐藏
  769. },
  770. onUnload: function() {
  771. // 页面卸载
  772. },
  773. onPullDownRefresh: function() {
  774. wx.stopPullDownRefresh();
  775. },
  776. onReachBottom: function() {
  777. // 上拉加载更多
  778. },
  779. onShareAppMessage: function() {
  780. return {
  781. title: '山东红色景点地图',
  782. path: '/pages/index/jingdianchaxun/jingdianchaxun',
  783. imageUrl: '/images/share.jpg'
  784. };
  785. },
  786. onPageScroll: function() {
  787. // 页面滚动
  788. },
  789. onTabItemTap: function(item) {
  790. // tab点击
  791. },
  792. onResize: function() {
  793. // 页面尺寸变化
  794. }
  795. });